DGLHeteroGraph.set_n_initializer(initializer, field=None, ntype=None)[source]

Set the initializer for empty node features.

Initializer is a callable that returns a tensor given the shape, data type and device context.

When a subset of the nodes are assigned a new feature, initializer is used to create feature for the rest of the nodes.

  • initializer (callable) – The initializer, mapping (shape, data type, context) to tensor.
  • field (str, optional) – The feature field name. Default is to set an initializer for all the feature fields.
  • ntype (str, optional) – The node type. Can be omitted if there is only one node type in the graph. Error will be raised otherwise. (Default: None)


User defined initializer must follow the signature of dgl.init.base_initializer()