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.



75
76
77
# File 'lib/dnn/core/savers.rb', line 75

def initialize(model)
  @model = model
end

Instance Method Details

#save(file_name) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/dnn/core/savers.rb', line 79

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