This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import numpy as np | |
import torch.nn as nn | |
from sklearn import datasets | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.model_selection import train_test_split | |
bc = datasets.load_breast_cancer() | |
x, y = bc.data, bc.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Design model (input, output size, forward pass) | |
# 2) Construct loss and optimizer | |
# 3) Training loop | |
# - forward pass: compute prediction | |
# - backward pass: gradients | |
# - update weights | |
import torch | |
import torch.nn as nn | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import numpy as np | |
# f = w * x | |
# f = 2 * x | |
X = np.array([1,2,3,4,5],dtype=np.float32) | |
Y = np.array([5,10,15,20,25],dtype=np.float32) | |
w = 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
''' | |
Backpropgation | |
eg. x = [1.,1.,1] -> "This is the fixed feature value:" | |
y = x + 2 -> a(x) -> "This is the respective y value:" | |
z = y*y*3 -> b(y) -> "This is the example for loss function" | |
Backpropgation x -> a(x) -> b(y) -> z | |
dz/dx = dz/dy * dy/dx (Chain Rule) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torchvision | |
from torch.utils.data import Dataset, DataLoader | |
import numpy as np | |
import math | |
class WineDataset(Dataset): | |
def __init__(self): | |
# Data Loading |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MNIST | |
# DataLoader Neural Net, activation function | |
# Loss and Optimizer | |
# Training Loop (batch training) | |
# Model evaluation | |
# GPU Support | |
import torch | |
import torch.nn as nn | |
import torchvision | |
import torchvision.transforms as transforms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torchvision | |
from torchvision.transforms import transforms | |
from torchvision import datasets | |
from torch.utils.data import DataLoader | |
import torch.nn.functional as F | |
# HyperParameter | |
device = torch.device('cuda' if torch.cuda.is_available else 'cpu') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import tensorflow as tf | |
import numpy as np | |
from functools import reduce | |
from sklearn.metrics import accuracy_score |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer