Spaces:
Sleeping
Sleeping
File size: 1,233 Bytes
031ac83 f9522cf 031ac83 f9522cf 92f14e0 f9522cf 4c97910 f9522cf 4c97910 031ac83 92f14e0 031ac83 4c97910 031ac83 4c97910 92f14e0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
from sklearn.model_selection import train_test_split
from neural_network.backprop import bp
import numpy as np
def get_args() -> dict:
"""
returns a dictionary containing
the arguments to be passed to
the main function
"""
return {
"epochs": int(input("Enter the number of epochs: ")),
"hidden_size": int(input("Enter the number of hidden nodes: ")),
"learning_rate": float(input("Enter the learning rate: ")),
"activation_func": input("Enter the activation function: "),
}
def init(X: np.array, y: np.array, hidden_size: int) -> dict:
"""
returns a dictionary containing randomly initialized
weights and biases to start off the neural_network
"""
return {
"W1": np.random.randn(X.shape[1], hidden_size),
"b1": np.zeros((1, hidden_size)),
"W2": np.random.randn(hidden_size, 1),
"b2": np.zeros((1, 1)),
}
def main(
X: np.array,
y: np.array,
) -> None:
args = get_args()
wb = init(X, y, args["hidden_size"])
X_train, X_test, y_train, y_test = train_test_split(
X,
y,
test_size=0.3,
random_state=8675309
)
results = bp(X_train, y_train, wb, args)
|