Initializers
Contents
Initializers#
empty#
- tensorkrowch.empty(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type
zeros#
- tensorkrowch.zeros(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type
ones#
- tensorkrowch.ones(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type
copy#
- tensorkrowch.copy(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type
rand#
- tensorkrowch.rand(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type
randn#
- tensorkrowch.randn(shape, param_node=False, *args, **kwargs)[source]#
Returns
Node
orParamNode
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 aNode
(False
).args – Arguments to initialize an
AbstractNode
.kwargs – Keyword arguments to initialize an
AbstractNode
.
- Return type