Tutorial 4 Flashcards
What is torch.device() used for?
A torch.device is an object representing the device on which a torch.Tensor is or will be allocated.
What is torch.cuda.is_available() used for?
It is used to check if a GPU is present. Returns True if so.
What class do you have to inherit from when creating a custom neural network?
nn.Module()
Which functions do you have to override?
def __init__() and def __forward()
What is def __init__() for?
This function is used to define all of your layers.
What is def __forward__() for?
This function is used to define the forward pass of your neural net.
What does model.children() return?
Returns all the submodules of the model in the form of a generator
What can you do with model.apply(f(n))
Apply a specific function to all the children of the model. An example is resetting the weights.
How do you reset all the weights of a model?
You create a function called weight_reset(m):, which does an m.reset_parameters() call. Then you feed this function to model.apply()