-
Notifications
You must be signed in to change notification settings - Fork 396
Add adam train #159
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
Merged
Merged
Add adam train #159
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
daedfc7
Add adam train
e6dc699
Fix: Preserve Adam optimizer state when copying networks
64ef659
feat: add backward compatibility for Adam optimizer parameters in net…
784ae2e
Add fann_update_weights_adam function declaration to fann_internal.h
0037cc0
feat: add Adam optimizer parameters to print and save output
e686ff0
chore: add robot_adam example artifacts to ignore list
28be6d0
Docs: correct version info for Adam optimizer functions in fann_train.h
2a09a13
fix: use sqrt instead of sqrtf in Adam optimizer
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,6 @@ cascade_train_debug | |
| xor_test_debug | ||
| xor_test_fixed_debug | ||
| xor_train_debug | ||
| robot_adam | ||
| robot_adam.net | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| Fast Artificial Neural Network Library (fann) | ||
| Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| This library is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| */ | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| #include "fann.h" | ||
|
|
||
| int main() | ||
| { | ||
| const unsigned int num_layers = 3; | ||
| const unsigned int num_neurons_hidden = 96; | ||
| const float desired_error = (const float) 0.00001; | ||
| struct fann *ann; | ||
| struct fann_train_data *train_data, *test_data; | ||
|
|
||
| unsigned int i = 0; | ||
|
|
||
| printf("Creating network.\n"); | ||
|
|
||
| train_data = fann_read_train_from_file("../datasets/robot.train"); | ||
|
|
||
| ann = fann_create_standard(num_layers, | ||
| train_data->num_input, num_neurons_hidden, train_data->num_output); | ||
|
|
||
| printf("Training network.\n"); | ||
|
|
||
| fann_set_training_algorithm(ann, FANN_TRAIN_ADAM); | ||
| fann_set_adam_beta1(ann, 0.9f); | ||
| fann_set_adam_beta2(ann, 0.999f); | ||
| fann_set_adam_epsilon(ann, 1e-8f); | ||
| fann_set_learning_rate(ann, 0.05f); | ||
|
|
||
| fann_train_on_data(ann, train_data, 10000, 100, desired_error); | ||
|
|
||
| printf("Testing network.\n"); | ||
|
|
||
| test_data = fann_read_train_from_file("../datasets/robot.test"); | ||
|
|
||
| fann_reset_MSE(ann); | ||
| for(i = 0; i < fann_length_train_data(test_data); i++) | ||
| { | ||
| fann_test(ann, test_data->input[i], test_data->output[i]); | ||
| } | ||
| printf("MSE error on test data: %f\n", fann_get_MSE(ann)); | ||
|
|
||
| printf("Saving network.\n"); | ||
|
|
||
| fann_save(ann, "robot_adam.net"); | ||
|
|
||
| printf("Cleaning up.\n"); | ||
| fann_destroy_train(train_data); | ||
| fann_destroy_train(test_data); | ||
| fann_destroy(ann); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.