lib/dnn/core/model.rb in ruby-dnn-0.1.4 vs lib/dnn/core/model.rb in ruby-dnn-0.1.5
- old
+ new
@@ -14,17 +14,20 @@
@optimizer = nil
@batch_size = nil
end
def save(file_name)
+ dir_name = file_name.match(%r`(.*)/.+$`)[1]
+ Dir.mkdir(dir_name) unless Dir.exist?(dir_name)
File.binwrite(file_name, Marshal.dump(self))
end
def <<(layer)
unless layer.is_a?(Layers::Layer)
raise DNN_TypeError.new("layer is not an instance of the DNN::Layers::Layer class.")
end
@layers << layer
+ self
end
def compile(optimizer)
unless optimizer.is_a?(Optimizers::Optimizer)
raise DNN_TypeError.new("optimizer is not an instance of the DNN::Optimizers::Optimizer class.")