Class: Chainer::AbstractSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/chainer/serializer.rb

Overview

Abstract base class of all serializers and deserializers.

Direct Known Subclasses

Deserializer, Serializer

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Gets a child serializer. This operator creates a child serializer represented by the given key.

Parameters:

  • key (string)

    Name of the child serializer.

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/chainer/serializer.rb', line 8

def [](key)
  raise NotImplementedError
end

#call(key, value) ⇒ Object

Serializes or deserializes a value by given name. This operator saves or loads a value by given name. If this is a serializer, then the value is simply saved at the key. Note that some type information might be missed depending on the implementation (and the target file format). If this is a deserializer, then the value is loaded by the key. The deserialization differently works on scalars and arrays. For scalars, the “value“ argument is used just for determining the type of restored value to be converted, and the converted value is returned. For arrays, the restored elements are directly copied into the “value“ argument. String values are treated like scalars.

Parameters:

  • key (string)

    Name of the serialization entry.

  • value (any)

    Object to be (de)serialized. “None“ is only supported by deserializers.

Returns:

  • Serialized or deserialized value.

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/chainer/serializer.rb', line 28

def call(key, value)
  raise NotImplementedError  
end