Pytorch_sentdex Flashcards
what is F and nn. Is there a relation between them
Yes, F is function and nn is more of Oops way. Pytorch has this difference due to architectural differences
what is the 1st and 2nd step in building the neural network
1st step is to define the structure of NN and next step is to define how the data is passed through the Network
what do you understand by flatten
Flattened is that all the data in the 28*28 form is converted into one continuous row
Basic code to form and check the layers
Roam -> Pytorch, #nn_layer_initialization
why wont this work #nn_data_pass
Because activation function is not defined
Name some standard optimizers and does the last layer needs activation function if no y if yes y
ReLu, LeakyRelu, Sigmoid, Tanh. Yes
For a probability distribution output, what is the best loss function? What is the dimension that is needed
Log_soft_max always work with multiclass classifier. Dim=1 You can further note that dim = 0.
Remember how to define the optimizer, loss
nn_init_forward_optim_loss. Can the loss be defined
How can you send a random training data into a nn and how your dimension of input data should look.
X.view(-1,28*28).
How to build a network where the 1st few layers are general layers and the rest of the later layers are specific layers
nn_logics_forward_cool.
If your output is numbers can you use MSE ?
No better use nll_loss. MSE can be used only for one hot encoded output value [0,0,0,1,0,0,0,0,0,0 ]
Why do we need to call zero_grad() in PyTorch?
In PyTorch, we need to set the gradients to zero before starting to do backpropragation because PyTorch accumulates the gradients on subsequent backward passes. This is convenient while training RNNs. So, the default action is to accumulate (i.e. sum) the gradients on every loss.backward() call.
TORCH.ARGMAX
Returns the indices of the maximum value of all elements in the input tensor.
COde to write one hot vector for multiclass classification
np.eye
vol = torch.unsqueeze(vol, 0) # Whats teh meaning of 0
0 represents the lockation at which the new dimension should be added