Class: DNN::Savers::Saver

Inherits:
Object
  • Object
show all
Defined in:
lib/dnn/core/savers.rb

Direct Known Subclasses

JSONSaver, MarshalSaver

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Saver

Returns a new instance of Saver.



67
68
69
# File 'lib/dnn/core/savers.rb', line 67

def initialize(model)
  @model = model
end

Instance Method Details

#save(file_name) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/dnn/core/savers.rb', line 71

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