class chainer.serializers.DictionarySerializer(target=None, path='')[source]

Serializer for dictionary.

This is the standard serializer in Chainer. The hierarchy of objects are simply mapped to a flat dictionary with keys representing the paths to objects in the hierarchy.


Despite of its name, this serializer DOES NOT serialize the object into external files. It just build a flat dictionary of arrays that can be fed into numpy.savez() and numpy.savez_compressed(). If you want to use this serializer directly, you have to manually send a resulting dictionary to one of these functions.

  • target (dict) – The dictionary that this serializer saves the objects to. If target is None, then a new dictionary is created.
  • path (str) – The base path in the hierarchy that this serializer indicates.

target (dict) – The target dictionary. Once the serialization completes, this dictionary can be fed into numpy.savez() or numpy.savez_compressed() to serialize it in the NPZ format.


__call__(key, value)[source]

Saves an object by this serializer.

This is equivalent to obj.serialize(self).

Parameters:obj – Target object to be serialized.