This structured self-learning journey into PyTorch focused on:
- tensor intuition
- mathematical understanding
- computational thinking
- multidimensional data manipulation
- deep learning foundations
This repository is not intended to be:
- an API dump
- copy-paste tutorial collection
- framework memorization guide
Instead, the goal is to develop:
operational intuition for tensor systems and computational mathematics.
Most PyTorch tutorials teach:
Framework Syntax → Neural Networks → Hope For Intuition
This repository follows a different path:
Tensor Intuition
↓
Mathematical Operations
↓
Computational Structures
↓
Deep Learning Foundations
The focus is on:
- understanding tensor behavior
- dimensional reasoning
- reduction systems
- computational graphs
- mathematical structure
before jumping into large models.
This project aims to build intuition for:
- tensors
- tensor geometry
- tensor manipulation
- automatic differentiation
- multidimensional computation
- linear algebra operations
- reduction systems
- computational graph reasoning
using progressively structured examples.
Introduction to:
torch- tensors
- tensor creation
- tensor properties
Concepts:
- tensor shapes
- datatypes
- devices
- multidimensional arrays
Covered APIs:
torch.tensor()
torch.Tensor()
torch.zeros()
torch.ones()
torch.empty()
torch.rand()
torch.randn()
torch.randint()
torch.arange()
torch.linspace()
torch.logspace()
torch.eye()
torch.full()
torch.zeros_like()
torch.ones_like()
torch.rand_like()
torch.randn_like()Concepts:
- memory allocation
- random initialization
- tensor factories
- Gaussian distributions
- identity matrices
Covered APIs:
tensor.shape
tensor.size()
tensor.dtype
tensor.device
tensor.ndim
tensor.numel()
tensor.requires_gradConcepts:
- tensor metadata
- shape analysis
- dimensionality
- gradient tracking
- device management
Covered APIs:
tensor.float()
tensor.double()
tensor.int()
tensor.long()
tensor.bool()
tensor.to()
tensor.cpu()
tensor.cuda()Concepts:
- datatype systems
- precision
- CPU/GPU movement
- memory representation
Covered APIs:
torch.cat()
torch.stack()
torch.split()
torch.chunk()
tensor.view()
tensor.reshape()
tensor.permute()
tensor.transpose()
tensor.squeeze()
tensor.unsqueeze()
tensor.flatten()
tensor.repeat()
tensor.expand()Concepts:
- shape transformations
- batching
- dimension reordering
- tensor replication
- broadcasting intuition
Covered APIs:
torch.add()
torch.sub()
torch.mul()
torch.div()
torch.matmul()
torch.mm()
torch.bmm()
torch.exp()
torch.log()
torch.sqrt()
torch.pow()
torch.abs()
torch.sin()
torch.cos()
torch.tanh()
torch.relu()
torch.sigmoid()Concepts:
- element-wise operations
- matrix multiplication
- activation functions
- exponential systems
- tensor algebra
Covered APIs:
torch.sum()
torch.mean()
torch.std()
torch.var()
torch.max()
torch.min()
torch.argmax()
torch.argmin()
torch.prod()Concepts:
- aggregation
- statistical summaries
- dimensional collapse
- reduction reasoning
Covered APIs:
torch.eq()
torch.ne()
torch.gt()
torch.lt()
torch.ge()
torch.le()
torch.where()Concepts:
- masking
- conditional tensor selection
- logical tensor systems
- thresholding
Covered APIs:
tensor.backward()
torch.autograd.grad()
torch.no_grad()
torch.enable_grad()
torch.set_grad_enabled()Concepts:
- computational graphs
- automatic differentiation
- chain rule
- gradient propagation
- backpropagation
Covered APIs:
tensor.requires_grad_()
tensor.detach()
tensor.clone()Concepts:
- graph detachment
- gradient control
- memory copying
- tensor tracking
Implemented beginner-friendly problems involving:
- tensor analysis
- reductions
- squeeze/unsqueeze
- averaging
- batching
- indexing
Example:
- Student Marks Tensor Analysis
Implemented:
- separable Gaussian filtering
- multidimensional tensor filtering
- grouped convolutions
- channel-wise operations
Concepts:
- tensor geometry
- signal processing intuition
- separable convolution
- computational optimization
The repository emphasizes:
Concept
↓
Mathematics
↓
Tensor Operation
↓
Algorithmic Thinking
↓
PyTorch Implementation
Each section typically includes:
- explanations
- mathematical formulas
- algorithmic intuition
- notebook exercises
- standalone scripts
This project intentionally bridges:
| Mathematics | PyTorch |
|---|---|
| Linear Algebra | Tensor Operations |
| Calculus | Autograd |
| Geometry | Tensor Shapes |
| Signal Processing | Convolutions |
| Optimization | Gradient Systems |
instead of treating PyTorch as merely a software library.
pytorch-self-learning/
│
├── basics/
│ ├── tensor_creation/
│ ├── tensor_information/
│ ├── tensor_manipulation/
│ ├── tensor_math/
│ ├── reductions/
│ ├── comparison_ops/
│ ├── autograd/
│ └── variables/
│
├── problems/
│ ├── beginner/
│ └── intermediate/
│
├── notebooks/
│
└── README.md
After learning how tensors represent images and perception systems in:
play_with_kalu
the repository now transitions into a deeper layer of tensor understanding:
Tensor Interaction Systems
This phase focuses on how tensors:
- align
- negotiate dimensions
- route information
- reorganize geometry
- control visibility
- interact structurally
The goal is to move beyond:
Tensor as container
toward:
Tensor as computational geometry system
This phase repeatedly emphasizes:
Tensor dimensions are not merely sizes.
They carry structural meaning.
Understanding tensor interaction systems is foundational for:
- CNNs
- transformers
- attention systems
- latent representations
- multimodal systems
- scientific computing
intermediate/
└── phase_02_tensor_interaction_systems/
├── step_01_tensor_broadcasting.py
├── step_02_broadcasting_geometry.py
├── step_03_tensor_indexing.py
├── step_04_boolean_masking.py
├── step_05_gather_scatter.py
├── step_06_tensor_memory_layout.py
├── step_07_tensor_permutation_systems.py
└── step_08_tensor_alignment_systems.py
This phase follows the progression:
Broadcasting
↓
Tensor Navigation
↓
Information Visibility
↓
Tensor Routing
↓
Memory Geometry
↓
Dimension Reorganization
↓
Representation Alignment
Core intuition:
Dimensions negotiate compatibility.
Topics:
- singleton dimensions
- implicit expansion
- broadcasting rules
- shape compatibility
- tensor interaction
Key insight:
Broadcasting is structured geometric alignment.
Core intuition:
Broadcasting is tensor geometry negotiation.
Topics:
- right-to-left alignment
- dimensional compatibility
- higher-dimensional broadcasting
- geometric expansion
- structural interaction
Key insight:
Tensor interaction depends on geometric compatibility.
Core intuition:
Indexing is tensor navigation.
Topics:
- tensor slicing
- dimensional traversal
- advanced indexing
- boolean indexing
- higher-dimensional indexing
Key insight:
Tensor indexing enables structured information access.
Core intuition:
Masks control information flow.
Topics:
- boolean tensors
- logical masking
- conditional selection
- masked computation
- sparse visibility
Key insight:
Masking enables selective tensor visibility.
Core intuition:
Tensors can dynamically route information.
Topics:
- gather()
- scatter()
- tensor routing
- sparse interaction
- dynamic indexing
Key insight:
Tensor systems can selectively redistribute information.
Core intuition:
Tensor geometry affects memory behavior.
Topics:
- contiguous tensors
- tensor storage
- memory layout
- tensor stride
- reshape vs view
Key insight:
A tensor is simultaneously geometry and memory.
Core intuition:
Dimension order changes tensor meaning.
Topics:
- permute()
- transpose()
- dimension reordering
- semantic structure
- tensor reinterpretation
Key insight:
Tensor dimensions encode semantic structure.
Core intuition:
Deep learning is structured tensor interaction.
Topics:
- tensor alignment
- representation compatibility
- interaction geometry
- embedding alignment
- attention alignment
Key insight:
Tensor systems interact through structural negotiation.
Phase 1 taught:
How tensors represent perception.
Phase 2 teaches:
How tensors structurally interact.
This transition is extremely important because modern AI systems fundamentally depend on:
- tensor alignment
- tensor routing
- dimension organization
- latent interaction systems
Most tutorials stop at:
- tensor creation
- tensor arithmetic
- basic neural networks
This repository intentionally explores:
The computational geometry of tensor systems.
These ideas form the foundation for understanding:
- transformers
- attention
- embeddings
- multimodal systems
- latent spaces
- representation learning
Nearly every modern AI architecture depends heavily on:
- broadcasting
- masking
- permutation
- alignment
- tensor routing
Understanding these deeply transforms how one understands AI systems.
This phase gradually reveals that deep learning systems are fundamentally:
large-scale tensor interaction systems
where dimensions carry:
- structure
- semantics
- geometry
- interaction meaning
rather than merely:
numerical storage.
Planned future sections include:
- convolution operations
- neural networks
- CNNs
- transformers
- attention mechanisms
- optimization
- CUDA programming
- custom autograd
- latent representations
- tensor geometry
- diffusion systems
This repository is especially useful for:
- self learners
- engineers transitioning from MATLAB
- scientific computing learners
- ML beginners wanting intuition
- researchers building tensor understanding
PyTorch is more than a deep learning framework.
It is fundamentally:
a multidimensional computational mathematics system.
The goal of this repository is to learn PyTorch not merely as:
- syntax
but as:
- tensor reasoning
- computational structure
- mathematical abstraction
- differentiable systems engineering.
git clone git@github.com:kncsolutions/pytorch-self-learning.gitEnter project directory:
cd pytorch-self-learningpython -m venv venvActivate environment:
source venv/bin/activatevenv\Scripts\activateInstall PyTorch.
Visit:
https://pytorch.org/get-started/locally/
or install CPU version directly:
pip install torch torchvision torchaudioInstall notebook support:
pip install notebook matplotlibExample:
python basics/tensor_creation.pyRun mathematical operations:
python basics/tensor_mathematics.pyRun tensor manipulation examples:
python basics/tensor_manipulation.pyStart notebook server:
jupyter notebookOpen notebook examples from:
notebooks/
Example notebooks:
notebooks/basics/tensor_creation.ipynb
notebooks/basics/tensor_mathematics.ipynb
notebooks/basics/tensor_manipulation.ipynb
Problem files are available in:
problems/beginner/
Example:
python problems/beginner/tensor_basic_task_easy.pySolutions are available in:
solutions/
Example:
python solutions/tensor_basic_task_easy_solution.pyIntermediate tensor systems demonstrations are available in:
problems/intermediate/
Example:
python problems/intermediate/tensor_basic_demonstration_advanced.py
Recommended progression:
1. Read notebook explanation
↓
2. Run standalone script
↓
3. Modify tensor values
↓
4. Observe tensor behavior
↓
5. Solve beginner problem
↓
6. Compare with solution
↓
7. Experiment independently
1. hello_pytorch.py
2. tensor_creation.py
3. tensor_information.py
4. tensor_type_conversion.py
5. tensor_manipulation.py
6. tensor_mathematics.py
7. tensor_reduction.py
8. tensor_comparison.py
9. tensor_autograd_playground.py
10. tensor_variable_operations.py
Do NOT merely read the code.
Try:
- changing tensor shapes
- modifying dimensions
- changing datatypes
- experimenting with reductions
- intentionally creating errors
Tensor intuition develops through experimentation.
Current project structure is compatible with:
- Jupyter Notebook
- VSCode
- PyCharm
- Spyder
- Linux terminal workflows
## Installation
### CPU Installation
```bash
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpupip install -r requirements.txtRun:
python
Then:
import torch
print(torch.__version__)
If PyTorch imports successfully, setup is complete.
Developed by:
Pallav Nandi Chaudhuri
This repository is part of a structured self-learning and research-oriented exploration into:
- PyTorch
- tensor systems
- computational mathematics
- deep learning foundations
- multidimensional computation
- differentiable systems
For:
- questions
- suggestions
- collaborations
- corrections
- learning discussions
- research-oriented conversations
feel free to connect through the repository discussions/issues section.
If this repository helps your learning journey, consider:
- starring the repository
- contributing improvements
- extending exercises
- experimenting independently
The objective of this repository is not merely:
- learning APIs
but developing:
- tensor intuition
- computational reasoning
- multidimensional thinking
- mathematical understanding of deep learning systems.
Learning PyTorch deeply means learning:
how modern AI systems manipulate structured numerical geometry.
This project is licensed under the MIT License.
See:
- LICENSE
- DISCLAIMER.md