<jupyter_start><jupyter_text>00. PyTorch Fundamentals Exercises 1. Documentation reading A big part of deep learning (and learning to code in general) is getting familiar with the documentation of a certain framework you're using. We'll be using the PyTorch documentation a lot throughout the rest of this course. So I'd recommend spending 10-minutes reading the following (it's okay if you don't get some things for now, the focus is not yet full understanding, it's awareness):  * The documentation on [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.htmltorch-tensor).  * The documentation on [`torch.cuda`](https://pytorch.org/docs/master/notes/cuda.htmlcuda-semantics).<jupyter_code># No code solution (reading)<jupyter_output><empty_output><jupyter_text>2. Create a random tensor with shape `(7, 7)`.<jupyter_code># Import torch


# Create random tensor<jupyter_output><empty_output><jupyter_text>3. Perform a matrix multiplication on the tensor from 2 with another random tensor with shape `(1, 7)` (hint: you may have to transpose the second tensor).<jupyter_code># Create another random tensor

# Perform matrix multiplication<jupyter_output><empty_output><jupyter_text>4. Set the random seed to `0` and do 2 & 3 over again.The output should be:```(tensor([[1.8542],         [1.9611],         [2.2884],         [3.0481],         [1.7067],         [2.5290],         [1.7989]]), torch.Size([7, 1]))```<jupyter_code># Set manual seed


# Create two random tensors


# Matrix multiply tensors<jupyter_output><empty_output><jupyter_text>5. Speaking of random seeds, we saw how to set it with `torch.manual_seed()` but is there a GPU equivalent? (hint: you'll need to look into the documentation for `torch.cuda` for this one)  * If there is, set the GPU random seed to `1234`.<jupyter_code># Set random seed on the GPU<jupyter_output><empty_output><jupyter_text>6. Create two random tensors of shape `(2, 3)` and send them both to the GPU (you'll need access to a GPU for this). Set `torch.manual_seed(1234)` when creating the tensors (this doesn't have to be the GPU random seed). The output should be something like:```Device: cuda(tensor([[0.0290, 0.4019, 0.2598],         [0.3666, 0.0583, 0.7006]], device='cuda:0'), tensor([[0.0518, 0.4681, 0.6738],         [0.3315, 0.7837, 0.5631]], device='cuda:0'))```<jupyter_code># Set random seed


# Check for access to GPU

# Create two random tensors on GPU<jupyter_output><empty_output><jupyter_text>7. Perform a matrix multiplication on the tensors you created in 6 (again, you may have to adjust the shapes of one of the tensors).The output should look like:```(tensor([[0.3647, 0.4709],         [0.5184, 0.5617]], device='cuda:0'), torch.Size([2, 2]))```<jupyter_code># Perform matmul on tensor_A and tensor_B<jupyter_output><empty_output><jupyter_text>8. Find the maximum and minimum values of the output of 7.<jupyter_code># Find max

# Find min<jupyter_output><empty_output><jupyter_text>9. Find the maximum and minimum index values of the output of 7.<jupyter_code># Find arg max


# Find arg min<jupyter_output><empty_output><jupyter_text>10. Make a random tensor with shape `(1, 1, 1, 10)` and then create a new tensor with all the `1` dimensions removed to be left with a tensor of shape `(10)`. Set the seed to `7` when you create it and print out the first tensor and it's shape as well as the second tensor and it's shape.The output should look like:```tensor([[[[0.5349, 0.1988, 0.6592, 0.6569, 0.2328, 0.4251, 0.2071, 0.6297,           0.3653, 0.8513]]]]) torch.Size([1, 1, 1, 10])tensor([0.5349, 0.1988, 0.6592, 0.6569, 0.2328, 0.4251, 0.2071, 0.6297, 0.3653,        0.8513]) torch.Size([10])```<jupyter_code># Set seed


# Create random tensor


# Remove single dimensions


# Print out tensors and their shapes<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12149777428646243, 'fraction_numerical': 0.0717465305053679, 'mean_word_length': 4.650887573964497, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '105066', 'license': 'MIT', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1258, 'n_words': 454, 'path': 'extras/exercises/00_pytorch_fundamentals_exercises.ipynb', 'repo_name': 'beneyal/pytorch-deep-learning', 'size': '3819'}