0
0
PyTorchml~10 mins

PyTorch vs TensorFlow comparison - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import PyTorch library.

PyTorch
import [1]
Drag options to blanks, or click blank then click option'
Atorch
Btensorflow
Ckeras
Dsklearn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing tensorflow instead of torch
Using keras or sklearn which are different libraries
2fill in blank
medium

Complete 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'
Atensor
Barray
Cmatrix
Dvariable
Attempts:
3 left
💡 Hint
Common Mistakes
Using torch.array which does not exist
Using torch.variable which is deprecated
3fill in blank
hard

Fix 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'
Aarray
Btensor
Cvariable
Dconstant
Attempts:
3 left
💡 Hint
Common Mistakes
Using tf.variable instead of tf.constant
Using tf.tensor which does not exist
4fill in blank
hard

Fill 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'
ALinear
Bout_features
CConv2d
Din_channels
Attempts:
3 left
💡 Hint
Common Mistakes
Using Conv2d which is for convolutional layers
Using in_channels which is not a parameter for Linear
5fill in blank
hard

Fill 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'
ADense
B10
C'relu'
DConv2D
Attempts:
3 left
💡 Hint
Common Mistakes
Using Conv2D which is for convolutional layers
Passing activation without quotes