Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
e160cce3
Commit
e160cce3
authored
Oct 02, 2019
by
Stefan Otte
Committed by
Francisco Massa
Oct 02, 2019
Browse files
More examples of functional transforms (#1402)
parent
8c3cea7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
docs/source/transforms.rst
docs/source/transforms.rst
+25
-1
No files found.
docs/source/transforms.rst
View file @
e160cce3
...
...
@@ -89,7 +89,9 @@ Functional transforms give you fine-grained control of the transformation pipeli
As opposed to the transformations above, functional transforms don't contain a random number
generator for their parameters.
That means you have to specify/generate all parameters, but you can reuse the functional transform.
For example, you can apply a functional transform to multiple images like this:
Example:
you can apply a functional transform with the same parameters to multiple images like this:
.. code:: python
...
...
@@ -104,5 +106,27 @@ For example, you can apply a functional transform to multiple images like this:
# more transforms ...
return image, segmentation
Example:
you can use a functional transform to build transform classes with custom behavior:
.. code:: python
import torchvision.transforms.functional as TF
import random
class MyRotationTransform:
"""Rotate by one of the given angles."""
def __init__(self, angles):
self.angles = angles
def __call__(self, x):
angle = random.choice(self.angles)
return TF.rotate(x, angle)
rotation_transform = MyRotationTransform(angles=[-30, -15, 0, 15, 30])
.. automodule:: torchvision.transforms.functional
:members:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment