Closed CreatureOX closed 5 years ago
Would you have a chance to share your notebook somewhere on GitHub? It's hard for me to debug your problem when I can't see the source code you're using.
Here is my repository NumpyNN
I've tried many times, but the error still occurs.
Super. I will try to find out what may be the problem.
@CreatureOX I think I already know what your problem is. The error occurred because some of the code you used was taken from an article on Medium and some from the repository. More specifically, the train
function you are using returns a three-piece tuple.
def train(X, Y, nn_architecture, epochs, learning_rate):
params_values = init_layers(nn_architecture, 2)
cost_history = []
accuracy_history = []
for i in range(epochs):
Y_hat, cache = full_forward_propagation(X, params_values, nn_architecture)
cost = get_cost_value(Y_hat, Y)
cost_history.append(cost)
accuracy = get_accuracy_value(Y_hat, Y)
accuracy_history.append(accuracy)
grads_values = full_backward_propagation(Y_hat, Y, cache, params_values, nn_architecture)
params_values = update(params_values, grads_values, nn_architecture, learning_rate)
return params_values, cost_history, accuracy_history # <---TUPLE
Note that in the code version used in the repository, this function returns only one of these elements.
return params_values
How can you solve this problem? In two ways:
train
function so that it returns only one item as it is in the repository.
ORtrain
function. Unpack the tuple in place, like this:
params_values, _, _ = train(np.transpose(X_train), np.transpose(y_train.reshape((y_train.shape[0], 1))), NN_ARCHITECTURE, 10000, 0.01)
I hope that everything is clear. Let us know if any further problems have occurred. Greetings.
thx for your detailed reply, It works!
Great! It's very nice to hear that.
I could use
but there is an error when I implement next step
Here is it
But I think params_values is a dictionary, Why is it? I have copied all the necessary code. btw, I use Juypter 6.7.0 in Anaconda3 & python 3.6.7