Authors : Alex Krizhevsky, Ilya Sutskever, and Geoffrey Hinton
This was one of the most influential publication in the field of Computer Vision.This model won the ILSVRC 2012 Competition.
import torch.nn as nn | |
class LRN(nn.Module): | |
def __init__(self, size, alpha=1e-4, beta=0.75, k=1): | |
super(LRN, self).__init__() | |
self.avg = nn.AvgPool3d(kernel_size =(size,1,1), stride=1, padding=int((size-1)/2)) | |
self.alpha = alpha | |
self.beta = beta | |
self.k = k | |
class AlexNet(nn.Module): | |
def __init__(self, classes=1000): | |
super(AlexNet, self).__init__() | |
self.features = nn.Sequential( | |
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2), | |
nn.ReLU(inplace=True), | |
nn.MaxPool2d(kernel_size=3, stride=2), | |
nn.Conv2d(64, 192, kernel_size=5, padding=2), | |
nn.ReLU(inplace=True), | |
nn.MaxPool2d(kernel_size=3, stride=2), |
x = torch.randn(1, 3, 224, 224).uniform_(0, 1) | |
alexnet = AlexNet() | |
alexnet(x).size() |
from skimage import io | |
import matplotlib.pyplot as plt | |
image = io.imread('https://cdn3.bigcommerce.com/s-nadnq/product_images/uploaded_images/20.jpg') | |
plt.imshow(image) | |
plt.grid(False) | |
plt.axis('off') | |
plt.show() |
import random | |
from scipy import ndarray | |
import skimage as sk | |
from skimage import transform | |
from skimage import util | |
def random_rotation(image_array: ndarray): | |
random_degree = random.uniform(-25, 25) | |
return sk.transform.rotate(image_array, random_degree) |
def dropout(X, drop_probability): | |
keep_probability = 1 - drop_probability | |
mask = np.random.uniform(0, 1.0, X.shape) < keep_probability | |
if keep_probability > 0.0: | |
scale = (1/keep_probability) | |
else: | |
scale = 0.0 | |
return mask * X * scale | |
import torch | |
x = np.random.randn(3,3) | |
x_tensor = torch.from_numpy(x) | |
dropout = torch.nn.Dropout(0.5) | |
dropout(x_tensor) |
X = np.random.rand(3,3) | |
print('Input X = \n',X) | |
w = np.random.normal(loc=0.0, scale=0.01, size=(3,1)) | |
print('\nInitialized weight w = \n',w) | |
bias = np.ones((3,1)) | |
print('\nInitialized bias b = \n',bias) | |
z = np.dot(X, w) + bias z |
Monte Carlo Prediction method reinforcement learning agent for BlackJack Game.
Temporal Difference methods like
Expected SARSA