-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Neural Network (Multilayer Perceptron) #1025
Conversation
Updating fork
Updating Fork
Updating Fork
Updating Fork
Updating fork
Is there any way to solve following :
|
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Excellent work Thanks 😄
Please note the comments.
Reviewed file neural_network.cpp
. Haven't reviewed vector_ops.hpp and haven't executed the code yet.
* @param file_name file from which model will be loaded (*.model) | ||
* @return instance of NeuralNetwork class with pretrained weights | ||
*/ | ||
NeuralNetwork load_model (const std::string &file_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function returns a class instance, for it to be usable, it'd require the implementation of a copy constructor
for this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested it with default copy constructor
and it works fine.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed response. I was waiting to get a change to execute and test the code. I did on GitPod using the link in the description and got the result below. I think there is some error in the code. Can you please review and fix. Thanks.
gitpod /workspace/C-Plus-Plus $ /workspace/C-Plus-Plus/build/machine_learning/neural_network
INFO: Network constructed successfully
===============================================================
+ MODEL SUMMARY +
===============================================================
1) Neurons : 4, Activation : none, Kernal Shape : (4, 4)
2) Neurons : 6, Activation : relu, Kernal Shape : (4, 6)
3) Neurons : 3, Activation : sigmoid, Kernal Shape : (6, 3)
===============================================================
INFO: Training Started
Training: Epoch 1/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 2/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 3/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 4/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 5/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 6/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 7/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 8/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 9/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 10/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 11/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 12/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 13/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 14/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 15/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 16/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 17/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 18/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 19/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 20/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 21/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 22/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 23/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 24/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 25/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 26/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 27/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 28/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 29/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 30/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 31/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 32/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 33/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 34/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 35/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 36/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 37/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 38/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 39/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 40/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 41/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 42/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 43/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 44/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 45/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 46/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 47/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 48/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 49/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 50/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 51/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 52/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 53/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 54/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 55/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 56/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 57/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 58/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 59/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 60/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 61/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 62/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 63/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 64/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 65/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 66/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 67/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 68/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 69/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 70/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 71/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 72/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 73/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 74/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 75/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 76/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 77/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 78/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 79/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 80/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 81/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 82/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 83/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 84/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 85/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 86/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 87/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 88/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 89/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 90/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 91/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 92/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 93/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 94/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 95/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 96/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 97/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 98/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 99/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
Training: Epoch 100/100, Loss: -nan, Accuracy: -nan, Taken time: 0 seconds
neural_network: ../machine_learning/neural_network.cpp:780: void test(): Assertion `machine_learning::argmax(myNN.single_predict({{6.4,2.9,4.3,1.3}})) == 1' failed.
Aborted (core dumped)
gitpod /workspace/C-Plus-Plus $
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the same output result as @kvedala's #1025 (review).
I have done as you said. I am actually getting some weird output. But when I run program with command line (i.e. |
Thank you very much !!! 🍾 One last thing. Actually I am bit new with this PR stuff. I can see review option on other PRs. Is it possible for me to do a review of PRs ? |
Absolutely. Please do provide your feedback while respecting other contributors :) |
@imdeep2905 Can you create a PR with the following fix:
|
Sure ! |
const bool &normalize, | ||
const int &slip_lines = 1) { | ||
std::ifstream in_file; // Ifstream to read file | ||
in_file.open(file_name.c_str(), std::ios::in); // Open file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, you can add a check, something like this:
if(!in_file.is_open()) {
std::cerr << "Unable to open file: "<< file_name << "\n";
exit(EXIT_FAILURE);
}
Description of Change
Added Neural Network as machine_learning/neural_network.cpp
Added Vector Ops as machine_learning/vector_ops.hpp (Operations required for Neural Network)
Added iris.csv as machine_learning/iris.csv (Training file for Network)
This will close #967
Checklist
Notes: