Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import PyTorch library.
PyTorch
import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing tensorflow instead of torch
Using keras or sklearn which are different libraries
✗ Incorrect
PyTorch is imported using the name torch.
2fill in blank
mediumComplete the code to create a tensor with PyTorch.
PyTorch
x = torch.[1]([1, 2, 3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using torch.array which does not exist
Using torch.variable which is deprecated
✗ Incorrect
PyTorch creates tensors using torch.tensor().
3fill in blank
hardFix the error in the TensorFlow code to create a constant tensor.
PyTorch
import tensorflow as tf x = tf.[1]([1, 2, 3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using tf.variable instead of tf.constant
Using tf.tensor which does not exist
✗ Incorrect
TensorFlow creates constant tensors using tf.constant().
4fill in blank
hardFill both blanks to create a simple neural network layer in PyTorch.
PyTorch
layer = torch.nn.[1](in_features=10, [2]=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Conv2d which is for convolutional layers
Using in_channels which is not a parameter for Linear
✗ Incorrect
PyTorch's fully connected layer is Linear with in_features and out_features.
5fill in blank
hardFill all three blanks to define a TensorFlow model with one dense layer.
PyTorch
import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.[1](units=[2], activation=[3]) ])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Conv2D which is for convolutional layers
Passing activation without quotes
✗ Incorrect
TensorFlow's dense layer is Dense with units and activation parameters.