mirror of
https://github.com/aladdinpersson/Machine-Learning-Collection.git
synced 2026-02-20 13:50:41 +00:00
Merge branch 'master' of https://github.com/aladdinpersson/Machine-Learning-Collection
This commit is contained in:
@@ -8,15 +8,14 @@ Programmed by Aladdin Persson <aladdin.persson at hotmail dot com>
|
|||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
import torch
|
import torch
|
||||||
import torchvision
|
import torchvision # torch package for vision related things
|
||||||
import torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functions
|
import torch.nn.functional as F # Parameterless functions, like (some) activation functions
|
||||||
import torch.optim as optim # For all Optimization algorithms, SGD, Adam, etc.
|
import torchvision.datasets as datasets # Standard datasets
|
||||||
import torch.nn.functional as F # All functions that don't have any parameters
|
import torchvision.transforms as transforms # Transformations we can perform on our dataset for augmentation
|
||||||
from torch.utils.data import (
|
from torch import optim # For optimizers like SGD, Adam, etc.
|
||||||
DataLoader,
|
from torch import nn # All neural network modules
|
||||||
) # Gives easier dataset managment and creates mini batches
|
from torch.utils.data import DataLoader # Gives easier dataset managment by creating mini batches etc.
|
||||||
import torchvision.datasets as datasets # Has standard datasets we can import in a nice way
|
from tqdm import tqdm # For a nice progress bar!
|
||||||
import torchvision.transforms as transforms # Transformations we can perform on our dataset
|
|
||||||
|
|
||||||
# Set device
|
# Set device
|
||||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||||
@@ -29,7 +28,7 @@ num_classes = 10
|
|||||||
sequence_length = 28
|
sequence_length = 28
|
||||||
learning_rate = 0.005
|
learning_rate = 0.005
|
||||||
batch_size = 64
|
batch_size = 64
|
||||||
num_epochs = 2
|
num_epochs = 3
|
||||||
|
|
||||||
# Recurrent neural network (many-to-one)
|
# Recurrent neural network (many-to-one)
|
||||||
class RNN(nn.Module):
|
class RNN(nn.Module):
|
||||||
@@ -101,18 +100,12 @@ class RNN_LSTM(nn.Module):
|
|||||||
|
|
||||||
|
|
||||||
# Load Data
|
# Load Data
|
||||||
train_dataset = datasets.MNIST(
|
train_dataset = datasets.MNIST(root="dataset/", train=True, transform=transforms.ToTensor(), download=True)
|
||||||
root="dataset/", train=True, transform=transforms.ToTensor(), download=True
|
test_dataset = datasets.MNIST(root="dataset/", train=False, transform=transforms.ToTensor(), download=True)
|
||||||
)
|
|
||||||
|
|
||||||
test_dataset = datasets.MNIST(
|
|
||||||
root="dataset/", train=False, transform=transforms.ToTensor(), download=True
|
|
||||||
)
|
|
||||||
|
|
||||||
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
||||||
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
||||||
|
|
||||||
# Initialize network
|
# Initialize network (try out just using simple RNN, or GRU, and then compare with LSTM)
|
||||||
model = RNN_LSTM(input_size, hidden_size, num_layers, num_classes).to(device)
|
model = RNN_LSTM(input_size, hidden_size, num_layers, num_classes).to(device)
|
||||||
|
|
||||||
# Loss and optimizer
|
# Loss and optimizer
|
||||||
@@ -121,7 +114,7 @@ optimizer = optim.Adam(model.parameters(), lr=learning_rate)
|
|||||||
|
|
||||||
# Train Network
|
# Train Network
|
||||||
for epoch in range(num_epochs):
|
for epoch in range(num_epochs):
|
||||||
for batch_idx, (data, targets) in enumerate(train_loader):
|
for batch_idx, (data, targets) in enumerate(tqdm(train_loader)):
|
||||||
# Get data to cuda if possible
|
# Get data to cuda if possible
|
||||||
data = data.to(device=device).squeeze(1)
|
data = data.to(device=device).squeeze(1)
|
||||||
targets = targets.to(device=device)
|
targets = targets.to(device=device)
|
||||||
@@ -134,16 +127,11 @@ for epoch in range(num_epochs):
|
|||||||
optimizer.zero_grad()
|
optimizer.zero_grad()
|
||||||
loss.backward()
|
loss.backward()
|
||||||
|
|
||||||
# gradient descent or adam step
|
# gradient descent update step/adam step
|
||||||
optimizer.step()
|
optimizer.step()
|
||||||
|
|
||||||
# Check accuracy on training & test to see how good our model
|
# Check accuracy on training & test to see how good our model
|
||||||
def check_accuracy(loader, model):
|
def check_accuracy(loader, model):
|
||||||
if loader.dataset.train:
|
|
||||||
print("Checking accuracy on training data")
|
|
||||||
else:
|
|
||||||
print("Checking accuracy on test data")
|
|
||||||
|
|
||||||
num_correct = 0
|
num_correct = 0
|
||||||
num_samples = 0
|
num_samples = 0
|
||||||
|
|
||||||
@@ -160,13 +148,10 @@ def check_accuracy(loader, model):
|
|||||||
num_correct += (predictions == y).sum()
|
num_correct += (predictions == y).sum()
|
||||||
num_samples += predictions.size(0)
|
num_samples += predictions.size(0)
|
||||||
|
|
||||||
print(
|
# Toggle model back to train
|
||||||
f"Got {num_correct} / {num_samples} with \
|
|
||||||
accuracy {float(num_correct)/float(num_samples)*100:.2f}"
|
|
||||||
)
|
|
||||||
# Set model back to train
|
|
||||||
model.train()
|
model.train()
|
||||||
|
return num_correct / num_samples
|
||||||
|
|
||||||
|
|
||||||
check_accuracy(train_loader, model)
|
print(f"Accuracy on training set: {check_accuracy(train_loader, model)*100:2f}")
|
||||||
check_accuracy(test_loader, model)
|
print(f"Accuracy on test set: {check_accuracy(test_loader, model)*100:.2f}")
|
||||||
|
|||||||
@@ -1,34 +1,33 @@
|
|||||||
"""
|
"""
|
||||||
Example code of a simple CNN network training on MNIST dataset.
|
A simple walkthrough of how to code a convolutional neural network (CNN)
|
||||||
The code is intended to show how to create a CNN network as well
|
using the PyTorch library. For demonstration we train it on the very
|
||||||
as how to initialize loss, optimizer, etc. in a simple way to get
|
common MNIST dataset of handwritten digits. In this code we go through
|
||||||
training to work with function that checks accuracy as well.
|
how to create the network as well as initialize a loss function, optimizer,
|
||||||
|
check accuracy and more.
|
||||||
|
|
||||||
Video explanation: https://youtu.be/wnK3uWv_WkU
|
Programmed by Aladdin Persson
|
||||||
Got any questions leave a comment on youtube :)
|
* 2020-04-08: Initial coding
|
||||||
|
* 2021-03-24: More detailed comments and small revision of the code
|
||||||
Programmed by Aladdin Persson <aladdin.persson at hotmail dot com>
|
|
||||||
* 2020-04-08 Initial coding
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functions
|
import torchvision # torch package for vision related things
|
||||||
import torch.optim as optim # For all Optimization algorithms, SGD, Adam, etc.
|
import torch.nn.functional as F # Parameterless functions, like (some) activation functions
|
||||||
import torch.nn.functional as F # All functions that don't have any parameters
|
import torchvision.datasets as datasets # Standard datasets
|
||||||
from torch.utils.data import (
|
import torchvision.transforms as transforms # Transformations we can perform on our dataset for augmentation
|
||||||
DataLoader,
|
from torch import optim # For optimizers like SGD, Adam, etc.
|
||||||
) # Gives easier dataset managment and creates mini batches
|
from torch import nn # All neural network modules
|
||||||
import torchvision.datasets as datasets # Has standard datasets we can import in a nice way
|
from torch.utils.data import DataLoader # Gives easier dataset managment by creating mini batches etc.
|
||||||
import torchvision.transforms as transforms # Transformations we can perform on our dataset
|
from tqdm import tqdm # For nice progress bar!
|
||||||
|
|
||||||
# Simple CNN
|
# Simple CNN
|
||||||
class CNN(nn.Module):
|
class CNN(nn.Module):
|
||||||
def __init__(self, in_channels=1, num_classes=10):
|
def __init__(self, in_channels=1, num_classes=10):
|
||||||
super(CNN, self).__init__()
|
super(CNN, self).__init__()
|
||||||
self.conv1 = nn.Conv2d(
|
self.conv1 = nn.Conv2d(
|
||||||
in_channels=1,
|
in_channels=in_channels,
|
||||||
out_channels=8,
|
out_channels=8,
|
||||||
kernel_size=(3, 3),
|
kernel_size=(3, 3),
|
||||||
stride=(1, 1),
|
stride=(1, 1),
|
||||||
@@ -51,7 +50,6 @@ class CNN(nn.Module):
|
|||||||
x = self.pool(x)
|
x = self.pool(x)
|
||||||
x = x.reshape(x.shape[0], -1)
|
x = x.reshape(x.shape[0], -1)
|
||||||
x = self.fc1(x)
|
x = self.fc1(x)
|
||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
@@ -59,24 +57,20 @@ class CNN(nn.Module):
|
|||||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||||
|
|
||||||
# Hyperparameters
|
# Hyperparameters
|
||||||
in_channel = 1
|
in_channels = 1
|
||||||
num_classes = 10
|
num_classes = 10
|
||||||
learning_rate = 0.001
|
learning_rate = 0.001
|
||||||
batch_size = 64
|
batch_size = 64
|
||||||
num_epochs = 5
|
num_epochs = 3
|
||||||
|
|
||||||
# Load Data
|
# Load Data
|
||||||
train_dataset = datasets.MNIST(
|
train_dataset = datasets.MNIST(root="dataset/", train=True, transform=transforms.ToTensor(), download=True)
|
||||||
root="dataset/", train=True, transform=transforms.ToTensor(), download=True
|
test_dataset = datasets.MNIST(root="dataset/", train=False, transform=transforms.ToTensor(), download=True)
|
||||||
)
|
|
||||||
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
||||||
test_dataset = datasets.MNIST(
|
|
||||||
root="dataset/", train=False, transform=transforms.ToTensor(), download=True
|
|
||||||
)
|
|
||||||
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
||||||
|
|
||||||
# Initialize network
|
# Initialize network
|
||||||
model = CNN().to(device)
|
model = CNN(in_channels=in_channels, num_classes=num_classes).to(device)
|
||||||
|
|
||||||
# Loss and optimizer
|
# Loss and optimizer
|
||||||
criterion = nn.CrossEntropyLoss()
|
criterion = nn.CrossEntropyLoss()
|
||||||
@@ -84,7 +78,7 @@ optimizer = optim.Adam(model.parameters(), lr=learning_rate)
|
|||||||
|
|
||||||
# Train Network
|
# Train Network
|
||||||
for epoch in range(num_epochs):
|
for epoch in range(num_epochs):
|
||||||
for batch_idx, (data, targets) in enumerate(train_loader):
|
for batch_idx, (data, targets) in enumerate(tqdm(train_loader)):
|
||||||
# Get data to cuda if possible
|
# Get data to cuda if possible
|
||||||
data = data.to(device=device)
|
data = data.to(device=device)
|
||||||
targets = targets.to(device=device)
|
targets = targets.to(device=device)
|
||||||
@@ -101,14 +95,7 @@ for epoch in range(num_epochs):
|
|||||||
optimizer.step()
|
optimizer.step()
|
||||||
|
|
||||||
# Check accuracy on training & test to see how good our model
|
# Check accuracy on training & test to see how good our model
|
||||||
|
|
||||||
|
|
||||||
def check_accuracy(loader, model):
|
def check_accuracy(loader, model):
|
||||||
if loader.dataset.train:
|
|
||||||
print("Checking accuracy on training data")
|
|
||||||
else:
|
|
||||||
print("Checking accuracy on test data")
|
|
||||||
|
|
||||||
num_correct = 0
|
num_correct = 0
|
||||||
num_samples = 0
|
num_samples = 0
|
||||||
model.eval()
|
model.eval()
|
||||||
@@ -123,12 +110,10 @@ def check_accuracy(loader, model):
|
|||||||
num_correct += (predictions == y).sum()
|
num_correct += (predictions == y).sum()
|
||||||
num_samples += predictions.size(0)
|
num_samples += predictions.size(0)
|
||||||
|
|
||||||
print(
|
|
||||||
f"Got {num_correct} / {num_samples} with accuracy {float(num_correct)/float(num_samples)*100:.2f}"
|
|
||||||
)
|
|
||||||
|
|
||||||
model.train()
|
model.train()
|
||||||
|
return num_correct/num_samples
|
||||||
|
|
||||||
|
|
||||||
check_accuracy(train_loader, model)
|
print(f"Accuracy on training set: {check_accuracy(train_loader, model)*100:.2f}")
|
||||||
check_accuracy(test_loader, model)
|
print(f"Accuracy on test set: {check_accuracy(test_loader, model)*100:.2f}")
|
||||||
@@ -1,60 +1,69 @@
|
|||||||
"""
|
"""
|
||||||
Working code of a simple Fully Connected (FC) network training on MNIST dataset.
|
A simple walkthrough of how to code a fully connected neural network
|
||||||
The code is intended to show how to create a FC network as well
|
using the PyTorch library. For demonstration we train it on the very
|
||||||
as how to initialize loss, optimizer, etc. in a simple way to get
|
common MNIST dataset of handwritten digits. In this code we go through
|
||||||
training to work with function that checks accuracy as well.
|
how to create the network as well as initialize a loss function, optimizer,
|
||||||
|
check accuracy and more.
|
||||||
|
|
||||||
Video explanation: https://youtu.be/Jy4wM2X21u0
|
Programmed by Aladdin Persson
|
||||||
Got any questions leave a comment on youtube :)
|
* 2020-04-08: Initial coding
|
||||||
|
* 2021-03-24: Added more detailed comments also removed part of
|
||||||
Programmed by Aladdin Persson <aladdin.persson at hotmail dot com>
|
check_accuracy which would only work specifically on MNIST.
|
||||||
* 2020-04-08 Initial coding
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
import torch
|
import torch
|
||||||
import torchvision
|
import torchvision # torch package for vision related things
|
||||||
import torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functions
|
import torch.nn.functional as F # Parameterless functions, like (some) activation functions
|
||||||
import torch.optim as optim # For all Optimization algorithms, SGD, Adam, etc.
|
import torchvision.datasets as datasets # Standard datasets
|
||||||
import torch.nn.functional as F # All functions that don't have any parameters
|
import torchvision.transforms as transforms # Transformations we can perform on our dataset for augmentation
|
||||||
from torch.utils.data import (
|
from torch import optim # For optimizers like SGD, Adam, etc.
|
||||||
DataLoader,
|
from torch import nn # All neural network modules
|
||||||
) # Gives easier dataset managment and creates mini batches
|
from torch.utils.data import DataLoader # Gives easier dataset managment by creating mini batches etc.
|
||||||
import torchvision.datasets as datasets # Has standard datasets we can import in a nice way
|
from tqdm import tqdm # For nice progress bar!
|
||||||
import torchvision.transforms as transforms # Transformations we can perform on our dataset
|
|
||||||
|
|
||||||
# Create Fully Connected Network
|
# Here we create our simple neural network. For more details here we are subclassing and
|
||||||
|
# inheriting from nn.Module, this is the most general way to create your networks and
|
||||||
|
# allows for more flexibility. I encourage you to also check out nn.Sequential which
|
||||||
|
# would be easier to use in this scenario but I wanted to show you something that
|
||||||
|
# "always" works.
|
||||||
class NN(nn.Module):
|
class NN(nn.Module):
|
||||||
def __init__(self, input_size, num_classes):
|
def __init__(self, input_size, num_classes):
|
||||||
super(NN, self).__init__()
|
super(NN, self).__init__()
|
||||||
|
# Our first linear layer take input_size, in this case 784 nodes to 50
|
||||||
|
# and our second linear layer takes 50 to the num_classes we have, in
|
||||||
|
# this case 10.
|
||||||
self.fc1 = nn.Linear(input_size, 50)
|
self.fc1 = nn.Linear(input_size, 50)
|
||||||
self.fc2 = nn.Linear(50, num_classes)
|
self.fc2 = nn.Linear(50, num_classes)
|
||||||
|
|
||||||
def forward(self, x):
|
def forward(self, x):
|
||||||
|
"""
|
||||||
|
x here is the mnist images and we run it through fc1, fc2 that we created above.
|
||||||
|
we also add a ReLU activation function in between and for that (since it has no parameters)
|
||||||
|
I recommend using nn.functional (F)
|
||||||
|
"""
|
||||||
|
|
||||||
x = F.relu(self.fc1(x))
|
x = F.relu(self.fc1(x))
|
||||||
x = self.fc2(x)
|
x = self.fc2(x)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
# Set device
|
# Set device cuda for GPU if it's available otherwise run on the CPU
|
||||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||||
|
|
||||||
# Hyperparameters
|
# Hyperparameters of our neural network which depends on the dataset, and
|
||||||
|
# also just experimenting to see what works well (learning rate for example).
|
||||||
input_size = 784
|
input_size = 784
|
||||||
num_classes = 10
|
num_classes = 10
|
||||||
learning_rate = 0.001
|
learning_rate = 0.001
|
||||||
batch_size = 64
|
batch_size = 64
|
||||||
num_epochs = 1
|
num_epochs = 3
|
||||||
|
|
||||||
# Load Data
|
# Load Training and Test data
|
||||||
train_dataset = datasets.MNIST(
|
train_dataset = datasets.MNIST(root="dataset/", train=True, transform=transforms.ToTensor(), download=True)
|
||||||
root="dataset/", train=True, transform=transforms.ToTensor(), download=True
|
test_dataset = datasets.MNIST(root="dataset/", train=False, transform=transforms.ToTensor(), download=True)
|
||||||
)
|
|
||||||
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)
|
||||||
test_dataset = datasets.MNIST(
|
|
||||||
root="dataset/", train=False, transform=transforms.ToTensor(), download=True
|
|
||||||
)
|
|
||||||
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)
|
||||||
|
|
||||||
# Initialize network
|
# Initialize network
|
||||||
@@ -66,7 +75,7 @@ optimizer = optim.Adam(model.parameters(), lr=learning_rate)
|
|||||||
|
|
||||||
# Train Network
|
# Train Network
|
||||||
for epoch in range(num_epochs):
|
for epoch in range(num_epochs):
|
||||||
for batch_idx, (data, targets) in enumerate(train_loader):
|
for batch_idx, (data, targets) in enumerate(tqdm(train_loader)):
|
||||||
# Get data to cuda if possible
|
# Get data to cuda if possible
|
||||||
data = data.to(device=device)
|
data = data.to(device=device)
|
||||||
targets = targets.to(device=device)
|
targets = targets.to(device=device)
|
||||||
@@ -85,15 +94,9 @@ for epoch in range(num_epochs):
|
|||||||
# gradient descent or adam step
|
# gradient descent or adam step
|
||||||
optimizer.step()
|
optimizer.step()
|
||||||
|
|
||||||
|
|
||||||
# Check accuracy on training & test to see how good our model
|
# Check accuracy on training & test to see how good our model
|
||||||
|
|
||||||
|
|
||||||
def check_accuracy(loader, model):
|
def check_accuracy(loader, model):
|
||||||
if loader.dataset.train:
|
|
||||||
print("Checking accuracy on training data")
|
|
||||||
else:
|
|
||||||
print("Checking accuracy on test data")
|
|
||||||
|
|
||||||
num_correct = 0
|
num_correct = 0
|
||||||
num_samples = 0
|
num_samples = 0
|
||||||
model.eval()
|
model.eval()
|
||||||
@@ -109,12 +112,9 @@ def check_accuracy(loader, model):
|
|||||||
num_correct += (predictions == y).sum()
|
num_correct += (predictions == y).sum()
|
||||||
num_samples += predictions.size(0)
|
num_samples += predictions.size(0)
|
||||||
|
|
||||||
print(
|
|
||||||
f"Got {num_correct} / {num_samples} with accuracy {float(num_correct)/float(num_samples)*100:.2f}"
|
|
||||||
)
|
|
||||||
|
|
||||||
model.train()
|
model.train()
|
||||||
|
return num_correct/num_samples
|
||||||
|
|
||||||
|
|
||||||
check_accuracy(train_loader, model)
|
print(f"Accuracy on training set: {check_accuracy(train_loader, model)*100:.2f}")
|
||||||
check_accuracy(test_loader, model)
|
print(f"Accuracy on test set: {check_accuracy(test_loader, model)*100:.2f}")
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ But also other things such as setting the device (GPU/CPU) and converting
|
|||||||
between different types (int, float etc) and how to convert a tensor to an
|
between different types (int, float etc) and how to convert a tensor to an
|
||||||
numpy array and vice-versa.
|
numpy array and vice-versa.
|
||||||
|
|
||||||
|
Programmed by Aladdin Persson
|
||||||
|
* 2020-06-27: Initial coding
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Programmed by Aladdin Persson <aladdin.persson at hotmail dot com>
|
|||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn # All neural network modules, nn.Linear, nn.Conv2d, BatchNorm, Loss functions
|
from torch import nn
|
||||||
|
|
||||||
|
|
||||||
class GoogLeNet(nn.Module):
|
class GoogLeNet(nn.Module):
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -38,22 +38,22 @@ If you have any specific video suggestion please make a comment on YouTube :)
|
|||||||
|
|
||||||
### Basics
|
### Basics
|
||||||
* [![Youtube Link][logo]](https://youtu.be/x9JiIFvlUwk) [Tensor Basics](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_tensorbasics.py)
|
* [![Youtube Link][logo]](https://youtu.be/x9JiIFvlUwk) [Tensor Basics](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_tensorbasics.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/Jy4wM2X21u0) [Feedforward Neural Network](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_simple_fullynet.py#L26-L35)
|
* [![Youtube Link][logo]](https://youtu.be/Jy4wM2X21u0) [Feedforward Neural Network](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_simple_fullynet.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/wnK3uWv_WkU) [Convolutional Neural Network](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/157a5f458f272a513eb6b4a19d6613aec32dc21c/ML/Pytorch/Basics/pytorch_simple_CNN.py#L25-L41)
|
* [![Youtube Link][logo]](https://youtu.be/wnK3uWv_WkU) [Convolutional Neural Network](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_simple_CNN.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/Gl2WXLIMvKA) [Recurrent Neural Network](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_rnn_gru_lstm.py)
|
* [![Youtube Link][logo]](https://youtu.be/Gl2WXLIMvKA) [Recurrent Neural Network](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_rnn_gru_lstm.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/jGst43P-TJA) [Bidirectional Recurrent Neural Network](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_bidirectional_lstm.py)
|
* [![Youtube Link][logo]](https://youtu.be/jGst43P-TJA) [Bidirectional Recurrent Neural Network](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_bidirectional_lstm.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/g6kQl_EFn84) [Loading and saving model](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_loadsave.py#L26-L34)
|
* [![Youtube Link][logo]](https://youtu.be/g6kQl_EFn84) [Loading and saving model](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_loadsave.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/ZoZHd0Zm3RY) [Custom Dataset (Images)](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/aba36b89b438ca8f608a186f4d61d1b60c7f24e0/ML/Pytorch/Basics/custom_dataset/custom_dataset.py#L12-L29)
|
* [![Youtube Link][logo]](https://youtu.be/ZoZHd0Zm3RY) [Custom Dataset (Images)](https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/Basics/custom_dataset)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/9sHcLvVXsns) [Custom Dataset (Text)](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/custom_dataset_txt/loader_customtext.py)
|
* [![Youtube Link][logo]](https://youtu.be/9sHcLvVXsns) [Custom Dataset (Text)](https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/Basics/custom_dataset_txt)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/qaDe0qQZ5AQ) [Transfer Learning and finetuning](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_pretrain_finetune.py#L33-L54)
|
* [![Youtube Link][logo]](https://youtu.be/qaDe0qQZ5AQ) [Transfer Learning and finetuning](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_pretrain_finetune.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/Zvd276j9sZ8) [Data augmentation using Torchvision](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_transforms.py#L56-L72)
|
* [![Youtube Link][logo]](https://youtu.be/Zvd276j9sZ8) [Data augmentation using Torchvision](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_transforms.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/rAdLwKJBvPM) [Data augmentation using Albumentations](https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/Basics/albumentations_tutorial)
|
* [![Youtube Link][logo]](https://youtu.be/rAdLwKJBvPM) [Data augmentation using Albumentations](https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/Basics/albumentations_tutorial)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/RLqsxWaQdHE) [TensorBoard Example](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/79f2e1928906f3cccbae6c024f3f79fd05262cd1/ML/Pytorch/Basics/pytorch_tensorboard_.py#L72-L120)
|
* [![Youtube Link][logo]](https://youtu.be/RLqsxWaQdHE) [TensorBoard Example](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_tensorboard_.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/y6IEcEBRZks) [Calculate Mean and STD of Images](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/55637e6afbb8cc8be6a63e04bbc899704f862911/ML/Pytorch/Basics/pytorch_std_mean.py#L41-L53)
|
* [![Youtube Link][logo]](https://youtu.be/y6IEcEBRZks) [Calculate Mean and STD of Images](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_std_mean.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/RKHopFfbPao) [Simple Progress bar]()
|
* [![Youtube Link][logo]](https://youtu.be/RKHopFfbPao) [Simple Progress bar](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_progress_bar.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/1SZocGaCAr8) [Deterministic Behavior](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/set_deterministic_behavior/pytorch_set_seeds.py)
|
* [![Youtube Link][logo]](https://youtu.be/1SZocGaCAr8) [Deterministic Behavior](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/set_deterministic_behavior/pytorch_set_seeds.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/P31hB37g4Ak) [Learning Rate Scheduler](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_lr_ratescheduler.py#L45-L78)
|
* [![Youtube Link][logo]](https://youtu.be/P31hB37g4Ak) [Learning Rate Scheduler](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_lr_ratescheduler.py)
|
||||||
* [![Youtube Link][logo]](https://youtu.be/xWQ-p_o0Uik) [Initialization of weights](https://github.com/AladdinPerzon/Machine-Learning-Collection/blob/804c45e83b27c59defb12f0ea5117de30fe25289/ML/Pytorch/Basics/pytorch_init_weights.py#L35-L49)
|
* [![Youtube Link][logo]](https://youtu.be/xWQ-p_o0Uik) [Initialization of weights](https://github.com/aladdinpersson/Machine-Learning-Collection/blob/master/ML/Pytorch/Basics/pytorch_init_weights.py)
|
||||||
|
|
||||||
|
|
||||||
### More Advanced
|
### More Advanced
|
||||||
|
|||||||
Reference in New Issue
Block a user