Class: DNN::Loaders::MarshalLoader

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

Instance Method Summary collapse

Methods inherited from Loader

#initialize, #load

Constructor Details

This class inherits a constructor from DNN::Loaders::Loader

Instance Method Details

#load_bin(bin) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dnn/core/savers.rb', line 23

def load_bin(bin)
  data = Marshal.load(Zlib::Inflate.inflate(bin))
  unless @model.class.name == data[:class]
    raise DNNError, "Class name is mismatch. Target model is #{@model.class.name}. But loading model is #{data[:class]}."
  end
  if data[:model]
    data[:model].instance_variables.each do |ivar|
      obj = data[:model].instance_variable_get(ivar)
      @model.instance_variable_set(ivar, obj)
    end
  end
  @model.set_all_params_data(data[:params])
end