Class: DNN::Savers::Saver
- Inherits:
-
Object
- Object
- DNN::Savers::Saver
- Defined in:
- lib/dnn/core/savers.rb
Direct Known Subclasses
Instance Method Summary collapse
- #dump_bin ⇒ Object
-
#initialize(model) ⇒ Saver
constructor
A new instance of Saver.
- #save(file_name) ⇒ Object
Constructor Details
#initialize(model) ⇒ Saver
Returns a new instance of Saver.
63 64 65 |
# File 'lib/dnn/core/savers.rb', line 63 def initialize(model) @model = model end |
Instance Method Details
#dump_bin ⇒ Object
78 79 80 |
# File 'lib/dnn/core/savers.rb', line 78 def dump_bin raise NotImplementedError, "Class '#{self.class.name}' has implement method 'dump_bin'" end |
#save(file_name) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dnn/core/savers.rb', line 67 def save(file_name) bin = dump_bin begin File.binwrite(file_name, bin) rescue Errno::ENOENT dir_name = file_name.match(%r`(.*)/.+$`)[1] Dir.mkdir(dir_name) File.binwrite(file_name, bin) end end |