Skip to content

Commit 01f97bd

Browse files
committed
Update features.py
1 parent 1b48ee6 commit 01f97bd

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

deeptrack/pytorch/features.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
2828
Examples
2929
--------
30-
>>> import numpy as np
3130
>>> import deeptrack as dt
32-
>>> from deeptrack.torch.features import ToTensor
31+
>>> from deeptrack.pytorch.features import ToTensor
3332
3433
Convert a NumPy image to a torch tensor:
3534
35+
>>> import numpy as np
36+
>>>
3637
>>> feature = (
3738
... dt.Value(value=np.zeros((32, 32), dtype=np.float32))
3839
... >> ToTensor()
@@ -79,25 +80,22 @@ class ToTensor(Feature):
7980
8081
Parameters
8182
----------
82-
dtype: torch.dtype | None, optional
83+
dtype: torch.dtype or None, optional
8384
Dtype to cast the resulting tensor to. If `None`, no dtype cast is
8485
performed.
85-
device: torch.device | str | None, optional
86+
device: torch.device or str or None, optional
8687
Device to move the tensor to. If `None`, no device transfer is
8788
performed.
8889
add_dim_to_number: bool, optional
8990
If `True`, scalar numbers are converted to a 1D tensor of shape `(1,)`.
9091
If `False`, scalar numbers are returned unchanged. Defaults to `False`.
91-
permute_mode: {"always", "never", "numpy", "numpy_and_not_int"}, optional
92+
permute_mode: "always", "never", "numpy", or "numpy_and_not_int"}, optional
9293
Controls channel-last to channel-first permutation:
93-
9494
- `"always"`: permute whenever the resulting tensor has `ndim > 2`
95-
- `"never"`: never permute
95+
- `"never"` (default): never permute
9696
- `"numpy"`: permute only if the input was a NumPy array
9797
- `"numpy_and_not_int"`: permute only if the input was a NumPy array
98-
and its dtype is not an integer dtype
99-
100-
Defaults to `"never"`.
98+
and its dtype is not an integer dtype
10199
102100
Notes
103101
-----
@@ -115,30 +113,27 @@ def __init__(
115113
permute_mode: _PERMUTE_MODE_ = "never",
116114
**kwargs: Any,
117115
) -> None:
118-
"""Initialize the `ToTensor` feature.
116+
"""Initialize the ToTensor feature.
119117
120118
Parameters
121119
----------
122-
dtype: torch.dtype | None, optional
120+
dtype: torch.dtype or None, optional
123121
Dtype to cast the resulting tensor to. If `None`, no dtype cast is
124122
performed.
125-
device: torch.device | str | None, optional
123+
device: torch.device or str or None, optional
126124
Device to move the tensor to. If `None`, no device transfer is
127125
performed.
128126
add_dim_to_number: bool, optional
129127
If `True`, scalar numbers are converted to a 1D tensor of shape
130128
`(1,)`. If `False`, scalar numbers are returned unchanged.
131129
Defaults to `False`.
132-
permute_mode: {"always", "never", "numpy", "numpy_and_not_int"}, optional
130+
permute_mode: "always", "never", "numpy", "numpy_and_not_int", optional
133131
Controls channel-last to channel-first permutation:
134-
135132
- `"always"`: permute whenever the resulting tensor has `ndim > 2`
136-
- `"never"`: never permute
133+
- `"never"` (default): never permute
137134
- `"numpy"`: permute only if the input was a NumPy array
138135
- `"numpy_and_not_int"`: permute only if the input was a NumPy
139136
array and its dtype is not an integer dtype
140-
141-
Defaults to `"never"`.
142137
**kwargs: Any
143138
Additional keyword arguments passed to the parent `Feature` class.
144139

0 commit comments

Comments
 (0)