iunets.utils module¶
-
iunets.utils.
get_num_channels
(input_shape_or_channels)¶ Small helper function which outputs the number of channels regardless of whether the input shape or the number of channels were passed.
-
iunets.utils.
print_iunet_layout
(iunet)¶
-
iunets.utils.
eye_like
(M, device=None, dtype=None)¶ Creates an identity matrix of the same shape as another matrix.
For matrix M, the output is same shape as M, if M is a (n,n)-matrix. If M is a batch of m matrices (i.e. a (m,n,n)-tensor), create a batch of (n,n)-identity-matrices.
- Args:
- M (torch.Tensor)A tensor of either shape (n,n) or (m,n,n), for
which either an identity matrix or a batch of identity matrices of the same shape will be created.
- device (torch.device, optional)The device on which the output
will be placed. By default, it is placed on the same device as M.
- dtype (torch.dtype, optional)The dtype of the output. By default,
it is the same dtype as M.
- Returns:
torch.Tensor : Identity matrix or batch of identity matrices.