Python Generators and Random Number Generation Quiz

HumourousBowenite avatar
HumourousBowenite
·
·
Download

Start Quiz

Study Flashcards

48 Questions

Match the following functions with their corresponding descriptions:

bernoulli = Draws binary random numbers (0 or 1) from a Bernoulli distribution normal = Returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given randint = Returns a tensor filled with random integers generated uniformly between low (inclusive) and high (exclusive) poisson = Returns a tensor of the same size as input with each element sampled from a Poisson distribution with rate parameter given by the corresponding element in input

Match the following functions with their corresponding descriptions:

manual_seed = Sets the seed for generating random numbers get_rng_state = Returns the random number generator state as a torch.ByteTensor set_rng_state = Sets the random number generator state torch.default_generator = Returns the default CPU torch.Generator

Match the following functions with their corresponding descriptions:

rand = Returns a tensor filled with random numbers from a uniform distribution on the interval $[ 0 , 1 )$ rand_like = Returns a tensor with the same size as input that is filled with random numbers from a uniform distribution on the interval $[ 0 , 1 )$ multinomial = Returns a tensor where each row contains num_samples indices sampled from the multinomial probability distribution located in the corresponding row of tensor input randint_like = Returns a tensor with the same shape as Tensor input filled with random integers generated uniformly between low (inclusive) and high (exclusive)

Match the following in-place random sampling functions with their respective distributions:

torch.Tensor.bernoulli_() = Bernoulli distribution torch.Tensor.cauchy_() = Cauchy distribution torch.Tensor.exponential_() = Exponential distribution torch.Tensor.geometric_() = Geometric distribution

Match the following functions with their descriptions:

torch.quasirandom.SobolEngine = An engine for generating (scrambled) Sobol sequences torch.save() = Saves an object to a disk file get_num_threads = Returns the number of threads used for parallelizing CPU operations set_num_threads = Sets the number of threads used for intraop parallelism on CPU

Match the following functions with their descriptions:

get_num_interop_threads = Returns the number of threads used for inter-op parallelism on CPU set_num_interop_threads = Sets the number of threads used for interop parallelism torch.Tensor.log_normal_() = Samples from the log-normal distribution torch.Tensor.uniform_() = Numbers sampled from the continuous uniform distribution

Match the following PyTorch context managers with their descriptions:

torch.no_grad() = Context-manager that disables gradient calculation torch.enable_grad() = Context-manager that enables gradient calculation torch.set_grad_enabled() = Context-manager that sets gradient calculation on or off torch.is_grad_enabled() = Returns True if grad mode is currently enabled

Match the following PyTorch commands with their effects on gradient calculation:

x = torch.zeros(1, requires_grad=True) = Creates a tensor with gradient computation enabled with torch.no_grad(): y = x * 2 = Performs a computation with gradient calculation disabled with torch.set_grad_enabled(is_train): y = x * 2 = Performs a computation with gradient calculation set according to the is_train variable torch.set_grad_enabled(False) = Globally disables gradient computation

Match the following PyTorch commands with their results:

y = x * 2; y.requires_grad = Returns True if x requires gradient and gradient computation is enabled with torch.no_grad(): y = x * 2; y.requires_grad = Returns False, as gradient computation is disabled within the block with torch.set_grad_enabled(is_train): y = x * 2; y.requires_grad = Returns the value of is_train, as gradient computation is set according to the is_train variable within the block torch.set_grad_enabled(False); y = x * 2; y.requires_grad = Returns False, as gradient computation is globally disabled

Match the following PyTorch functions with their descriptions:

torch.abs() = Computes the absolute value of each element in input. torch.acos() = Computes the inverse cosine of each element in input. torch.add() = Adds other, scaled by alpha, to input. torch.angle() = Computes the element-wise angle (in radians) of the given input tensor.

Match the following PyTorch functions with their operations:

torch.asin() = Returns a new tensor with the arcsine of the elements of input. torch.atan() = Returns a new tensor with the arctangent of the elements of input. torch.addcdiv() = Performs the element-wise division of tensor1 by tensor2, multiplies the result by the scalar value and adds it to input. torch.addcmul() = Performs the element-wise multiplication of tensor1 by tensor2, multiplies the result by the scalar value and adds it to input.

Match the following PyTorch functions with their descriptions:

torch.atan2() = Element-wise arctangent of input $\frac{input_i}{other_i}$ with consideration of the quadrant. torch.asinh() = Returns a new tensor with the inverse hyperbolic sine of the elements of input. torch.acosh() = Returns a new tensor with the inverse hyperbolic cosine of the elements of input. torch.atanh() = Returns a new tensor with the inverse hyperbolic tangent of the elements of input.

Match the following PyTorch functions with their descriptions:

bitwise_not = Computes the bitwise NOT of the given input tensor bitwise_and = Computes the bitwise AND of input and other bitwise_or = Computes the bitwise OR of input and other bitwise_xor = Computes the bitwise XOR of input and other

Match the following PyTorch functions with their descriptions:

bitwise_left_shift = Computes the left arithmetic shift of input by other bits bitwise_right_shift = Computes the right arithmetic shift of input by other bits ceil = Returns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element clamp = Clamps all elements in input into the range [ min, max ]

Match the following PyTorch functions with their descriptions:

clip = Alias for torch.clamp() conj_physical = Computes the element-wise conjugate of the given input tensor copysign = Create a new floating-point tensor with the magnitude of input and the sign of other, elementwise cos = Returns a new tensor with the cosine of the elements of input

Match the following PyTorch functions with their descriptions:

cosh = Returns a new tensor with the hyperbolic cosine of the elements of input deg2rad = Returns a new tensor with each of the elements of input converted from angles in degrees to radians div = Divides each element of the input input by the corresponding element of other divide = Alias for torch.div()

Match the following PyTorch functions with their descriptions:

digamma = Alias for torch.special.digamma() erf = Alias for torch.special.erf() erfc = Alias for torch.special.erfc() erfinv = Alias for torch.special.erfinv()

Match the following PyTorch functions with their descriptions:

exp = Returns a new tensor with the exponential of the elements of the input tensor input exp2 = Alias for torch.special.exp2() expm1 = Alias for torch.special.expm1() fake_quantize_per_channel_affine = Returns a new tensor with the data in input fake quantized per channel using scale, zero_point, quant_min and quant_max, across the channel specified by axis

Match the following PyTorch functions with their descriptions:

fake_quantize_per_tensor_affine = Returns a new tensor with the data in input fake quantized using scale, zero_point, quant_min and quant_max. float_power = Raises input to the power of exponent, elementwise, in double precision. gradient = Estimates the gradient of a function in one or more dimensions using the second-order accurate central differences method. ldexp = Multiplies input by $2^{\text{other}}$.

Match the following PyTorch functions with their descriptions:

lgamma = Computes the natural logarithm of the absolute value of the gamma function on input. log1p = Returns a new tensor with the natural logarithm of $(1 + \text{input})$. logaddexp2 = Logarithm of the sum of exponentiations of the inputs in base-2. logical_not = Computes the element-wise logical NOT of the given input tensor.

Match the following PyTorch functions with their descriptions:

hypot = Given the legs of a right triangle, return its hypotenuse. mul = Multiplies input by other. nan_to_num = Replaces NaN, positive infinity, and negative infinity values in input with the values specified by nan, posinf, and neginf, respectively. negative = Returns a new tensor with the negative of the elements of input.

Match the following PyTorch functions with their descriptions:

pow = Takes the power of each element in input with exponent and returns a tensor with the result. quantized_max_pool1d = Applies a 1D max pooling over an input quantized tensor composed of several input planes. reciprocal = Returns a new tensor with the reciprocal of the elements of input remainder = Computes Python's modulus operation entrywise.

Match the following PyTorch functions with their descriptions:

rsqrt = Returns a new tensor with the reciprocal of the square-root of each of the elements of input. sign = Returns a new tensor with the signs of the elements of input. sin = Returns a new tensor with the sine of the elements of input. sqrt = Returns a new tensor with the square-root of the elements of input.

Match the following PyTorch functions with their descriptions:

sub = Subtracts other, scaled by alpha, from input. tan = Returns a new tensor with the tangent of the elements of input. tanh = Returns a new tensor with the hyperbolic tangent of the elements of input. true_divide = Alias for torch.div() with rounding_mode=None.

Match the following PyTorch functions with their descriptions:

lerp = Does a linear interpolation of two tensors start (given by input) and end based on a scalar or tensor weight and returns the resulting out tensor. log = Returns a new tensor with the natural logarithm of the elements of input. log10 = Returns a new tensor with the logarithm to the base 10 of the elements of input. log2 = Returns a new tensor with the logarithm to the base 2 of the elements of input.

Match the following PyTorch functions with their descriptions:

logit = Alias for torch.special.logit(). i0 = Alias for torch.special.i0(). igamma = Alias for torch.special.gammainc(). igammac = Alias for torch.special.gammaincc().

Match the following PyTorch functions with their descriptions:

mvlgamma = Alias for torch.special.multigammaln(). nextafter = Return the next floating-point value after input towards other, elementwise. polygamma = Alias for torch.special.polygamma(). positive = Returns input.

Match the following PyTorch functions with their descriptions:

quantized_batch_norm = Applies batch normalization on a 4D (NCHW) quantized tensor. quantized_max_pool2d = Applies a 2D max pooling over an input quantized tensor composed of several input planes. rad2deg = Returns a new tensor with each of the elements of input converted from angles in radians to degrees. real = Returns a new tensor containing real values of the self tensor.

Match the following PyTorch functions with their descriptions:

fake_quantize_per_tensor_affine = Returns a new tensor with the data in input fake quantized using scale, zero_point, quant_min, and quant_max. float_power = Raises input to the power of exponent, elementwise, in double precision. ldexp = Multiplies input by $2^{other}$. logical_xor = Computes the element-wise logical XOR of the given input tensors.

Match the following PyTorch functions with their descriptions:

log = Returns a new tensor with the natural logarithm of the elements of input. mul = Multiplies input by other. nan_to_num = Replaces NaN, positive infinity, and negative infinity values in input with the values specified by nan, posinf, and neginf, respectively. reciprocal = Returns a new tensor with the reciprocal of the elements of input.

Match the following PyTorch functions with their descriptions:

real = Returns a new tensor containing real values of the self tensor. quantized_max_pool2d = Applies a 2D max pooling over an input quantized tensor composed of several input planes. rsqrt = Returns a new tensor with the reciprocal of the square-root of each of the elements of input. sign = Returns a new tensor with the signs of the elements of input.

Match the following PyTorch functions with their descriptions:

sin = Returns a new tensor with the sine of the elements of input. sqrt = Returns a new tensor with the square-root of the elements of input. sub = Subtracts other, scaled by alpha, from input. tanh = Returns a new tensor with the hyperbolic tangent of the elements of input.

Match the following PyTorch functions with their descriptions:

logit = Alias for torch.special.logit(). lgamma = Computes the natural logarithm of the absolute value of the gamma function on input. quantized_batch_norm = Applies batch normalization on a 4D (NCHW) quantized tensor. floor_divide = Applies C++'s std::fmod entrywise.

Match the following PyTorch functions with their descriptions:

lerp = Does a linear interpolation of two tensors start (given by input) and end based on a scalar or tensor weight and returns the resulting out tensor. logaddexp2 = Logarithm of the sum of exponentiations of the inputs in base-2. sigmoid = Alias for torch.special.expit(). hypot = Given the legs of a right triangle, return its hypotenuse.

Match the following PyTorch functions with their descriptions:

log1p = Returns a new tensor with the natural logarithm of (1 + input). log10 = Returns a new tensor with the logarithm to the base 10 of the elements of input. log2 = Returns a new tensor with the logarithm to the base 2 of the elements of input. logaddexp = Logarithm of the sum of exponentiations of the inputs.

Match the following PyTorch functions with their descriptions:

gradient = Estimates the gradient of a function $g : R^n \rightarrow R$ in one or more dimensions using the second-order accurate central differences method. imag = Returns a new tensor containing imaginary values of the self tensor. frac = Computes the fractional portion of each element in input. frexp = Decomposes input into mantissa and exponent tensors such that $input = mantissa \times 2^{exponent}$.

Match the following PyTorch functions with their descriptions:

floor = Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element. fmod = Applies C++'s std::fmod entrywise. rad2deg = Returns a new tensor with each of the elements of input converted from angles in radians to degrees. square = Returns a new tensor with the square of the elements of input.

Match the following PyTorch functions with their descriptions:

nextafter = Return the next floating-point value after input towards other, elementwise. signbit = Tests if each element of input has its sign bit set or not. tan = Returns a new tensor with the tangent of the elements of input. true_divide = Alias for torch.div() with rounding_mode=None.

Match the following PyTorch functions with their descriptions:

fake_quantize_per_tensor_affine = Fake quantizes the data in input using scale, zero_point, quant_min and quant_max float_power = Raises input to the power of exponent, elementwise, in double precision log = Returns a new tensor with the natural logarithm of the elements of input mul = Multiplies input by other

Match the following PyTorch functions with their descriptions:

neg = Returns a new tensor with the negative of the elements of input log10 = Returns a new tensor with the logarithm to the base 10 of the elements of input ldexp = Multiplies input by 2 ** other logit = Alias for torch.special.logit()

Match the following PyTorch functions with their descriptions:

logical_and = Computes the element-wise logical AND of the given input tensors hypot = Given the legs of a right triangle, return its hypotenuse log2 = Returns a new tensor with the logarithm to the base 2 of the elements of input igamma = Alias for torch.special.gammainc()

Match the following PyTorch functions with their descriptions:

quantized_max_pool1d = Applies a 1D max pooling over an input quantized tensor composed of several input planes real = Returns a new tensor containing real values of the self tensor sin = Returns a new tensor with the sine of the elements of input tanh = Returns a new tensor with the hyperbolic tangent of the elements of input

Match the following PyTorch functions with their descriptions:

sqrt = Returns a new tensor with the square-root of the elements of input polygamma = Alias for torch.special.polygamma() floor = Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element reciprocal = Returns a new tensor with the reciprocal of the elements of input

Match the following PyTorch functions with their descriptions:

sigmoid = Alias for torch.special.expit() logaddexp = Logarithm of the sum of exponentiations of the inputs sub = Subtracts other, scaled by alpha, from input round = Rounds elements of input to the nearest integer

Match the following PyTorch functions with their descriptions:

tan = Returns a new tensor with the tangent of the elements of input imag = Returns a new tensor containing imaginary values of the self tensor logaddexp2 = Logarithm of the sum of exponentiations of the inputs in base-2 gradient = Estimates the gradient of a function in one or more dimensions using the second-order accurate central differences method

Match the following PyTorch functions with their descriptions:

log1p = Returns a new tensor with the natural logarithm of (1 + input) lerp = Does a linear interpolation of two tensors start (given by input) and end based on a scalar or tensor weight and returns the resulting out tensor lgamma = Computes the natural logarithm of the absolute value of the gamma function on input rsqrt = Returns a new tensor with the reciprocal of the square-root of each of the elements of input

Match the following PyTorch functions with their descriptions:

nan_to_num = Replaces NaN, positive infinity, and negative infinity values in input with the values specified by nan, posinf, and neginf, respectively signbit = Tests if each element of input has its sign bit set or not quantized_max_pool2d = Applies a 2D max pooling over an input quantized tensor composed of several input planes remainder = Computes Python's modulus operation entrywise

Match the following PyTorch functions with their descriptions:

sign = Returns a new tensor with the signs of the elements of input nextafter = Return the next floating-point value after input towards other, elementwise logical_xor = Computes the element-wise logical XOR of the given input tensors frexp = Decomposes input into mantissa and exponent tensors such that input = mantissa × 2 exponent input=mantissa×2 exponent

Test your knowledge on generators and random number generation in Python with this quiz. Learn about creating generator objects, setting random number seeds, and more.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Random Sampling Methods Overview
37 questions
Random Sampling Methods in Statistics
10 questions
Use Quizgecko on...
Browser
Browser