Skip to content

Add save and load methods #8

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 3 commits into from
Sep 28, 2017

Conversation

hugoabonizio
Copy link
Contributor

This PR adds #save and .load methods to, respectively, save a given network configuration to a file and load a network from a given file.

Examples:

Saving

ann = Fann::Network::Standard.new(2, [2], 1)
500.times do
  ann.train_single([1.0, 0.1], [0.5])
end
result = ann.run([1.0, 0.1])
puts result
ann.save("/tmp/network.config")
ann.close

Loading

nn = Fann::Network::Standard.load("/tmp/test.save")
puts nn.run([1.0, 0.1])

Fixes #7.

WDYT @bararchy?


def initialize(input : Int32, output : Int32)
@output_size = output
@input_size = input
@nn = LibFANN.create_shortcut(2, input, output)
end

def initialize(@nn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about, for load we just have 2 initializes

  1. regular
  2. for string
new(5,5)
# or
new("load/from/this/path")

What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion! 👍

@@ -17,6 +19,12 @@ module Fann
@nn = LibFANN.create_standard_array(layers.size, layers.to_unsafe)
end

def initialize(@nn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in Cascade

@bararchy
Copy link
Member

Overall, great work :) thank you for helping out.

@bararchy
Copy link
Member

@hugoabonizio Looks nice and tests passes, merging.

@bararchy bararchy merged commit b6b337e into NeuraLegion:master Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need to add save to file and load from file methods to networks
2 participants