 DeepLearning/Tensor/RandomCrop - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : DeepLearning Package : Tensors : Operations on Tensors : DeepLearning/Tensor/RandomCrop

DeepLearning/Tensor/RandomCrop

randomly crop a Tensor to specified shape

DeepLearning/Tensor/RandomShuffle

randomly shuffle a Tensor along its first dimension

 Calling Sequence RandomCrop(t,shape,opts) RandomShuffle(t,opts)

Parameters

 t - Tensor shape - list of integers opts - zero or more options as specified below

Options

 • name=string

The value of option name specifies an optional name for this Tensor, to be displayed in output and when visualizing the dataflow graph.

 • seed=integer

The value of option seed specifies an initial seed for the random number generator. It is equivalent to invoking SetRandomSeed(seed). For more information see SetRandomSeed.

Description

 • The RandomCrop(t,shape,opts) command constructs a Tensor with shape shape by randomly slicing data from t with uniform probability.
 • The RandomShuffle(t,opts) command randomly shuffles a Tensor along its first dimension.

Examples

Crop a random 3x2 slice from a 4x3 Tensor.

 > $\mathrm{with}\left(\mathrm{DeepLearning}\right):$
 > $C≔\mathrm{Constant}\left(⟨⟨3.5,7.9,-0.5,1⟩|⟨-3.8,-4.2,9.5,3⟩|⟨4.,-7.2,-8.2,2⟩⟩\right)$
 ${C}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: Const:0}}\\ {\mathrm{Shape: \left[4, 3\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (1)
 > $\mathrm{t1}≔\mathrm{RandomCrop}\left(C,\left[3,2\right]\right)$
 ${\mathrm{t1}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: random_crop:0}}\\ {\mathrm{Shape: \left[3, 2\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (2)
 > $\mathrm{Shape}\left(\mathrm{t1}\right)$
 $\left[{3}{,}{2}\right]$ (3)

Shuffle a Tensor along its first dimension.

 > $\mathrm{t2}≔\mathrm{RandomShuffle}\left(C\right)$
 ${\mathrm{t2}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: RandomShuffle:0}}\\ {\mathrm{Shape: \left[4, 3\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (4)

Compatibility

 • The DeepLearning/Tensor/RandomCrop and DeepLearning/Tensor/RandomShuffle commands were introduced in Maple 2018.
 • For more information on Maple 2018 changes, see Updates in Maple 2018.

 See Also