PyTorch Torch APIs
42 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Match the following PyTorch functions with their descriptions:

is_tensor = Returns True if obj is a PyTorch tensor. numel = Returns the total number of elements in the input tensor. set_default_dtype = Sets the default floating point dtype to d. is_nonzero = Returns True if the input is a single element tensor which is not equal to zero after type conversions.

Match the following PyTorch functions with their correct usage:

is_complex = Returns True if the data type of input is a complex data type. is_floating_point = Returns True if the data type of input is a floating point data type. set_default_device = Sets the default torch.Tensor to be allocated on device. set_printoptions = Set options for printing.

Match the following PyTorch functions with their descriptions:

get_default_dtype = Get the current default floating point torch.dtype. is_conj = Returns True if the input is a conjugated tensor. set_default_tensor_type = Sets the default torch.Tensor type to floating point tensor type t. set_flush_denormal = Disables denormal floating numbers on CPU.

Match the following PyTorch functions with their purpose:

<p>torch.rand() = Random sampling tensor = Constructs a tensor with no autograd history as_tensor = Converts data into a tensor, sharing data and preserving autograd history if possible from_numpy = Creates a Tensor from a numpy.ndarray</p> Signup and view all the answers

Match the following PyTorch functions with their functionality:

<p>sparse_csc_tensor = Constructs a sparse tensor in CSC (Compressed Sparse Column) format sparse_bsr_tensor = Constructs a sparse tensor in BSR (Block Compressed Sparse Row) format asarray = Converts obj to a tensor as_strided = Create a view of an existing torch.Tensor input with specified size, stride and storage_offset</p> Signup and view all the answers

Match the following PyTorch functions with their descriptions:

<p>torch.randint() = Random sampling sparse_coo_tensor = Constructs a sparse tensor in COO(rdinate) format from_dlpack = Converts a tensor from an external library into a torch.Tensor torch.empty() = Use with In-place random sampling methods to create torch.Tensor s with values sampled from a broader range of distributions</p> Signup and view all the answers

Match the following PyTorch functions with their definitions:

<p>dequantize = Returns an fp32 Tensor by dequantizing a quantized Tensor complex = Constructs a complex tensor with its real part equal to real and its imaginary part equal to imag polar = Constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value abs and angle angle heaviside = Computes the Heaviside step function for each element in input</p> Signup and view all the answers

Match the following PyTorch functions to their descriptions:

<p>polar = Constructs a complex tensor based on polar coordinates complex = Creates a complex tensor using real and imaginary parts dequantize = Transforms a quantized Tensor to an fp32 Tensor heaviside = Applies the Heaviside step function on each element in input</p> Signup and view all the answers

Associate the PyTorch functions with their correct definitions:

<p>complex = Forms a complex tensor from real and imag parts dequantize = Converts a quantized Tensor to an fp32 Tensor heaviside = Calculates the Heaviside step function for input elements polar = Builds a complex tensor from polar coordinates</p> Signup and view all the answers

Match the following PyTorch functions with their descriptions:

<p>frombuffer = Creates a 1-dimensional Tensor from an object that implements the Python buffer protocol. zeros = Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size. arange = Returns a 1-D tensor of size $\lceil \frac{end - start}{step} \rceil$ with values from the interval [start, end) taken with common difference step beginning from start. full = Creates a tensor of size size filled with fill_value.</p> Signup and view all the answers

Match the following PyTorch functions with their descriptions:

<p>ones = Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument size. range = Returns a 1-D tensor of size $\lfloor \frac{end - start}{step} \rfloor + 1$ with values from start to end with step step. linspace = Creates a one-dimensional tensor of size steps whose values are evenly spaced from start to end, inclusive. eye = Returns a 2-D tensor with ones on the diagonal and zeros elsewhere.</p> Signup and view all the answers

Match the following PyTorch functions with their descriptions:

<p>empty = Returns a tensor filled with uninitialized data. empty_strided = Creates a tensor with the specified size and stride and filled with undefined data. quantize_per_tensor = Converts a float tensor to a quantized tensor with given scale and zero point. quantize_per_channel = Converts a float tensor to a per-channel quantized tensor with given scales and zero points.</p> Signup and view all the answers

Associate the following PyTorch functions with their respective functionalities:

<p>adjoint = Returns a view of the tensor conjugated and with the last two dimensions transposed. argwhere = Returns a tensor containing the indices of all non-zero elements of input. cat = Concatenates the given sequence of seq tensors in the given dimension. concat = Alias of torch.cat().</p> Signup and view all the answers

Match the PyTorch functions with their corresponding descriptions:

<p>concatenate = Alias of torch.cat(). conj = Returns a view of input with a flipped conjugate bit. chunk = Attempts to split a tensor into the specified number of chunks. dsplit = Splits input, a tensor with three or more dimensions, into multiple tensors depthwise according to indices_or_sections.</p> Signup and view all the answers

Pair up the following PyTorch functions with their definitions:

<p>column_stack = Creates a new tensor by horizontally stacking the tensors in tensors. dstack = Stack tensors in sequence depthwise (along third axis). gather = Gathers values along an axis specified by dim. hsplit = Splits input, a tensor with one or more dimensions, into multiple tensors horizontally according to indices_or_sections.</p> Signup and view all the answers

Link the PyTorch functions to their respective functionalities:

<p>hstack = Stack tensors in sequence horizontally (column wise). index_add = See index_add_() for function description. index_copy = See index_add_() for function description. index_reduce = See index_reduce_() for function description.</p> Signup and view all the answers

Associate the following PyTorch functions with their correct definitions:

<p>index_select = Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. masked_select = Returns a new 1-D tensor which indexes the input tensor according to the boolean mask mask which is a BoolTensor. movedim = Moves the dimension(s) of input at the position(s) in source to the position(s) in destination. moveaxis = Alias for torch.movedim().</p> Signup and view all the answers

Match the following PyTorch functions with their respective descriptions:

<p>narrow = Returns a new tensor that is a narrowed version of input tensor. narrow_copy = Same as Tensor.narrow() except this returns a copy rather than shared storage. adjoint = Returns a view of the tensor conjugated and with the last two dimensions transposed. argwhere = Returns a tensor containing the indices of all non-zero elements of input.</p> Signup and view all the answers

Connect the PyTorch functions to their corresponding functionalities:

<p>cat = Concatenates the given sequence of seq tensors in the given dimension. concat = Alias of torch.cat(). conj = Returns a view of input with a flipped conjugate bit. chunk = Attempts to split a tensor into the specified number of chunks.</p> Signup and view all the answers

Pair the following PyTorch functions with their definitions:

<p>dsplit = Splits input, a tensor with three or more dimensions, into multiple tensors depthwise according to indices_or_sections. column_stack = Creates a new tensor by horizontally stacking the tensors in tensors. dstack = Stack tensors in sequence depthwise (along third axis). gather = Gathers values along an axis specified by dim.</p> Signup and view all the answers

Associate the following PyTorch functions with their correct functionalities:

<p>hsplit = Splits input, a tensor with one or more dimensions, into multiple tensors horizontally according to indices_or_sections. hstack = Stack tensors in sequence horizontally (column wise). index_add = See index_add_() for function description. index_copy = See index_add_() for function description.</p> Signup and view all the answers

Link the PyTorch functions to their corresponding descriptions:

<p>index_reduce = See index_reduce_() for function description. index_select = Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. masked_select = Returns a new 1-D tensor which indexes the input tensor according to the boolean mask mask which is a BoolTensor. movedim = Moves the dimension(s) of input at the position(s) in source to the position(s) in destination.</p> Signup and view all the answers

Match the following PyTorch functions with their operations:

<p>nonzero = Returns a view of the original tensor input with its dimensions permuted reshape = Returns a tensor with the same data and number of elements as input, but with the specified shape row_stack = Alias of torch.vstack() select = Slices the input tensor along the selected dimension at the given index</p> Signup and view all the answers

Associate the following PyTorch functions with their functionalities:

<p>scatter = Out-of-place version of torch.Tensor.scatter_() diagonal_scatter = Embeds the values of the src tensor into input along the diagonal elements of input, with respect to dim1 and dim2 select_scatter = Embeds the values of the src tensor into input at the given index slice_scatter = Embeds the values of the src tensor into input at the given dimension</p> Signup and view all the answers

Link the following PyTorch functions to their descriptions:

<p>scatter_add = Out-of-place version of torch.Tensor.scatter_add_() scatter_reduce = Out-of-place version of torch.Tensor.scatter_reduce_() split = Splits the tensor into chunks squeeze = Returns a tensor with all specified dimensions of input of size 1 removed</p> Signup and view all the answers

Associate the following PyTorch functions with their operations:

<p>stack = Concatenates a sequence of tensors along a new dimension swapaxes = Alias for torch.transpose() swapdims = Alias for torch.transpose() t = Expects input to be &lt;= 2-D tensor and transposes dimensions 0 and 1</p> Signup and view all the answers

Match the following PyTorch functions to their functionalities:

<p>take = Returns a new tensor with the elements of input at the given indices take_along_dim = Selects values from input at the 1-dimensional indices from indices along the given dim tensor_split = Splits a tensor into multiple sub-tensors, all of which are views of input, along dimension dim according to the indices or number of sections specified by indices_or_sections tile = Constructs a tensor by repeating the elements of input</p> Signup and view all the answers

Link the following PyTorch functions with their operations:

<p>transpose = Returns a tensor that is a transposed version of input unbind = Removes a tensor dimension unsqueeze = Returns a new tensor with a dimension of size one inserted at the specified position vsplit = Splits input, a tensor with two or more dimensions, into multiple tensors vertically according to indices_or_sections</p> Signup and view all the answers

Match the following PyTorch functions to their definitions:

<p>vstack = Stack tensors in sequence vertically (row wise) where = Return a tensor of elements selected from either input or other, depending on condition nonzero = Returns a view of the original tensor input with its dimensions permuted reshape = Returns a tensor with the same data and number of elements as input, but with the specified shape</p> Signup and view all the answers

Associate the following PyTorch functions with their descriptions:

<p>row_stack = Alias of torch.vstack() select = Slices the input tensor along the selected dimension at the given index scatter = Out-of-place version of torch.Tensor.scatter_() diagonal_scatter = Embeds the values of the src tensor into input along the diagonal elements of input, with respect to dim1 and dim2</p> Signup and view all the answers

Link the following PyTorch functions to their functionalities:

<p>select_scatter = Embeds the values of the src tensor into input at the given index slice_scatter = Embeds the values of the src tensor into input at the given dimension scatter_add = Out-of-place version of torch.Tensor.scatter_add_() scatter_reduce = Out-of-place version of torch.Tensor.scatter_reduce_()</p> Signup and view all the answers

Match the following PyTorch functions with their operations:

<p>split = Splits the tensor into chunks squeeze = Returns a tensor with all specified dimensions of input of size 1 removed stack = Concatenates a sequence of tensors along a new dimension swapaxes = Alias for torch.transpose()</p> Signup and view all the answers

Match the following PyTorch functions with their appropriate descriptions:

<p>permute = Returns a view of the original tensor input with its dimensions permuted. scatter = Out-of-place version of torch.Tensor.scatter_() tensor_split = Splits a tensor into multiple sub-tensors, all of which are views of input, along dimension dim according to the indices or number of sections specified by indices_or_sections. vsplit = Splits input, a tensor with two or more dimensions, into multiple tensors vertically according to indices_or_sections.</p> Signup and view all the answers

Link the following PyTorch functions to their corresponding descriptions:

<p>unsqueeze = Returns a new tensor with a dimension of size one inserted at the specified position. take_along_dim = Selects values from input at the 1-dimensional indices from indices along the given dim. swapdims = Alias for torch.transpose(). scatter_add = Out-of-place version of torch.Tensor.scatter_add_()</p> Signup and view all the answers

Pair the following PyTorch functions with their appropriate functionalities:

<p>reshape = Returns a tensor with the same data and number of elements as input, but with the specified shape. select_scatter = Embeds the values of the src tensor into input at the given index. unbind = Removes a tensor dimension. t = Expects input to be &lt;= 2-D tensor and transposes dimensions 0 and 1.</p> Signup and view all the answers

Associate the following PyTorch functions with their respective descriptions:

<p>slice_scatter = Embeds the values of the src tensor into input at the given dimension. vstack = Stack tensors in sequence vertically (row wise). tile = Constructs a tensor by repeating the elements of input. take = Returns a new tensor with the elements of input at the given indices.</p> Signup and view all the answers

Match the following PyTorch functions with their correct functionalities:

<p>where = Return a tensor of elements selected from either input or other, depending on condition. scatter_reduce = Out-of-place version of torch.Tensor.scatter_reduce_() swapaxes = Alias for torch.transpose(). squeeze = Returns a tensor with all specified dimensions of input of size 1 removed.</p> Signup and view all the answers

Connect the following PyTorch functions to their corresponding functionalities:

<p>select = Slices the input tensor along the selected dimension at the given index. row_stack = Alias of torch.vstack(). diagonal_scatter = Embeds the values of the src tensor into input along the diagonal elements of input, with respect to dim1 and dim2. stack = Concatenates a sequence of tensors along a new dimension.</p> Signup and view all the answers

Link the following PyTorch functions to their respective descriptions:

<p>split = Splits the tensor into chunks. transpose = Returns a tensor that is a transposed version of input. nonzero = Returns a tensor with all the non-zero elements of the input tensor. stack = Concatenates a sequence of tensors along a new dimension.</p> Signup and view all the answers

Pair up the following PyTorch functions with their definitions:

<p>reshape = Returns a tensor with the same data and number of elements as input, but with the specified shape. squeeze = Returns a tensor with all specified dimensions of input of size 1 removed. unbind = Removes a tensor dimension. vstack = Stack tensors in sequence vertically (row wise).</p> Signup and view all the answers

Associate the following PyTorch functions with their correct definitions:

<p>select = Slices the input tensor along the selected dimension at the given index. scatter = Out-of-place version of torch.Tensor.scatter_() unsqueeze = Returns a new tensor with a dimension of size one inserted at the specified position. take = Returns a new tensor with the elements of input at the given indices.</p> Signup and view all the answers

Match the following PyTorch functions to their descriptions:

<p>permute = Returns a view of the original tensor input with its dimensions permuted. scatter_add = Out-of-place version of torch.Tensor.scatter_add_() swapdims = Alias for torch.transpose(). tensor_split = Splits a tensor into multiple sub-tensors, all of which are views of input, along dimension dim according to the indices or number of sections specified by indices_or_sections.</p> Signup and view all the answers

More Like This

PyTorch
15 questions

PyTorch

HumourousBowenite avatar
HumourousBowenite
PyTorch Random Number Generation Quiz
60 questions
Use Quizgecko on...
Browser
Browser