lib/dnn/core/model.rb in ruby-dnn-0.8.6 vs lib/dnn/core/model.rb in ruby-dnn-0.8.7

- old
+ new

@@ -35,11 +35,11 @@ next unless layer.is_a?(HasParamLayer) hash_params = has_param_layers_params[has_param_layers_index] hash_params.each do |key, (shape, base64_param)| bin = Base64.decode64(base64_param) data = Xumo::SFloat.from_binary(bin).reshape(*shape) - if layer.params[key].is_a?(LearningParam) + if layer.params[key].is_a?(Param) layer.params[key].data = data else layer.params[key] = data end end @@ -66,12 +66,11 @@ def params_to_json has_param_layers = @layers.select { |layer| layer.is_a?(Layers::HasParamLayer) } has_param_layers_params = has_param_layers.map do |layer| layer.params.map { |key, param| - param = param.data if param.is_a?(LearningParam) - base64_param = Base64.encode64(param.to_binary) - [key, [param.shape, base64_param]] + base64_data = Base64.encode64(param.data.to_binary) + [key, [param.data.shape, base64_data]] }.to_h end JSON.dump(has_param_layers_params) end