Initializers#

empty#

tensorkrowch.empty(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode without tensor.

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode

zeros#

tensorkrowch.zeros(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode filled with zeros.

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode

ones#

tensorkrowch.ones(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode filled with ones.

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode

copy#

tensorkrowch.copy(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode with a copy tensor, that is, a tensor filled with zeros except in the diagonal (elements \(T_{i_1 \ldots i_n}\) with \(i_1 = \ldots = i_n\)), which is filled with ones.

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode

rand#

tensorkrowch.rand(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode filled with elements drawn from a uniform distribution \(U(low, high)\).

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode

randn#

tensorkrowch.randn(shape, param_node=False, *args, **kwargs)[source]#

Returns Node or ParamNode filled with elements drawn from a normal distribution \(N(mean, std)\).

Parameters
  • shape (list[int], tuple[int] or torch.Size) – Node’s shape, that is, the shape of its tensor.

  • param_node (bool) – Boolean indicating whether the node should be a ParamNode (True) or a Node (False).

  • args – Arguments to initialize an AbstractNode.

  • kwargs – Keyword arguments to initialize an AbstractNode.

Return type

Node or ParamNode