New Flashcards

1
Q

What is the purpose of the BigramLanguageModel class in PyTorch?

A

It is designed to predict the next token based on the current token using a lookup table for embeddings.

The model uses a vocabulary size to create a token embedding table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the forward method in the BigramLanguageModel class do?

A

It takes input indices and targets, and returns logits from the token embedding table.

The logits shape is (B, T, C), where B is batch size, T is sequence length, and C is vocabulary size.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the torch.allclose function do?

A

It returns true if two tensors are close in value, within a specified tolerance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of the nn.Sequential class in PyTorch?

A

It allows you to create a neural network by stacking layers in a sequential manner.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can layers be passed to nn.Sequential?

A

Layers can be passed as:
* Direct arguments
* List
* Tuple with names
* OrderedDict

Each method provides a different way to organize and name the layers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the torch.clamp function do?

A

It clamps the values of a tensor within a specified range.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the structure of a tensor created with requires_grad=True?

A

It allows for gradient accumulation during backpropagation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Fill in the blank: In PyTorch, you can use _______ to apply multiple transformations to a dataset.

A

transforms.Compose

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the function of the TransformedDataset class?

Make an example

A

It wraps an original dataset and applies transformations to its items when accessed.

from torch.utils.data import Dataset

class TransformedDataset(Dataset):
    def \_\_init\_\_(self, dataset, transform=None):
        self.dataset = dataset
        self.transform = transform

    def \_\_getitem\_\_(self, idx):
        data = self.dataset[idx]
        
        if self.transform is not None:
            data = self.transform(data)
            
        return data

    def \_\_len\_\_(self):
        return len(self.dataset)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the __getitem__ method do in the TransformedDataset class?

A

It retrieves an item from the original dataset and applies the transformation if provided.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is TMUX used for in Linux?

A

It is a terminal multiplexer that allows users to create and manage multiple terminal sessions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: The command ‘ctrl b + %’ in TMUX splits the window vertically.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What command is used to detach from a TMUX session?

A

ctrl b + d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the command ‘grep [pattern] [file_directory]’ do?

A

It searches for a specified pattern within files in the given directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of the manual_seed function in PyTorch?

A

It sets the seed for generating random numbers for reproducibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the output of accessing y.grad_fn in the context of PyTorch tensors?

A

It provides the gradient function that generated the tensor y.

17
Q

Fill in the blank: In terminal, to create a new horizontal pane in TMUX, you use the command _______.

A

ctrl + b + “

18
Q

What does the wei tensor represent in the context of matrix multiplication?

A

It represents a weighted aggregation used for causal sums.