0
0
TensorFlowml~10 mins

TensorFlow vs PyTorch 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 TensorFlow library.

TensorFlow
import [1] as tf
Drag options to blanks, or click blank then click option'
Asklearn
Btensorflow
Ckeras
Dtorch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'torch' which is PyTorch's library name.
Using 'keras' which is a high-level API.
2fill in blank
medium

Complete the code to create a tensor with PyTorch.

TensorFlow
import torch
x = [1]([1, 2, 3])
Drag options to blanks, or click blank then click option'
ATensor
BVariable
CTensorFlow
Dtensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Tensor' which is incorrect capitalization.
Using 'Variable' which is deprecated.
3fill in blank
hard

Fix the error in the TensorFlow code to create a constant tensor.

TensorFlow
import tensorflow as tf
x = tf.[1]([1, 2, 3])
Drag options to blanks, or click blank then click option'
Aconstant
BTensor
CVariable
Dtensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Variable' instead of 'constant'.
Using 'Tensor' which is not a TensorFlow function.
4fill in blank
hard

Fill both blanks to define a simple linear model in PyTorch.

TensorFlow
import torch.nn as nn
model = nn.[1](in_features=10, [2]=1)
Drag options to blanks, or click blank then click option'
ALinear
Bout_features
Cin_features
DConv2d
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Conv2d' which is a convolutional layer.
Using 'in_features' twice instead of 'out_features'.
5fill in blank
hard

Fill all three blanks to compile and train a TensorFlow model.

TensorFlow
model.compile(optimizer='[1]', loss='[2]', metrics=['[3]'])
model.fit(x_train, y_train, epochs=5)
Drag options to blanks, or click blank then click option'
Aadam
Bsparse_categorical_crossentropy
Caccuracy
Dsgd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sgd' optimizer with incompatible loss.
Using 'categorical_crossentropy' instead of 'sparse_categorical_crossentropy' for integer labels.