SkalskiP / ILearnDeepLearning.py

This repository contains small projects related to Neural Networks and Deep Learning in general. Subjects are closely linekd with articles I publish on Medium. I encourage you both to read as well as to check how the code works in the action.
https://medium.com/@skalskip
MIT License
1.33k stars 466 forks source link

numpy implemented model can not work #2

Closed jasstionzyf closed 5 years ago

jasstionzyf commented 5 years ago

i copy all the necessary code from your provided Numpy deep neural network.ipynb ,
when i run the code ,Test set accuracy: 0.48 always keep 0.48. obviously this is not right

SkalskiP commented 5 years ago
  1. I am very sorry that you had to wait so long for an answer. I did not receive a notification that you reported the problem.

  2. A few words of explanation at the beginning. The code in the notebook is the most basic version of the neural network. I mentioned this in my article. As a result, it may fall into certain traps, such as, for example, a disappearing gradient and so on... In order to deal with such problems, certain optimisation techniques are introduced. However, they are not included in this implementation. If you look in the logs by setting the verbose flag to true, you will see that the value of the cost function decreases. But it does it extremely slowly.

  3. As to your problem. From what I see you have used a very small neural network.

nn_architecture = [ {"input_dim": 2, "output_dim": 4, "activation": "relu"}, {"input_dim": 4, "output_dim": 6, "activation": "relu"}, {"input_dim": 6, "output_dim": 6, "activation": "relu"}, {"input_dim": 6, "output_dim": 4, "activation": "relu"}, {"input_dim": 4, "output_dim": 1, "activation": "sigmoid"}, ]

Eventually, in my notebook I decided on such an architecture:

NN_ARCHITECTURE = [ {"input_dim": 2, "output_dim": 25, "activation": "relu"}, {"input_dim": 25, "output_dim": 50, "activation": "relu"}, {"input_dim": 50, "output_dim": 50, "activation": "relu"}, {"input_dim": 50, "output_dim": 25, "activation": "relu"}, {"input_dim": 25, "output_dim": 1, "activation": "sigmoid"}, ]

Please let me know if something has changed. Do you see an improvement?

jasstionzyf commented 5 years ago

thanks for your reply! yes , you are right , i just though it is a ready demo program .
i have use your suggestions, it works!