-
Monte Carlo Prediction method reinforcement learning agent for BlackJack Game.
-
Temporal Difference methods like
- SARSA(0)
- SARSAMAX(Q-Learning)
-
Expected SARSA
This file contains 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 requests | |
import os | |
import tarfile | |
# Hugging Face token | |
hf_token = "<HF_TOKEN_HERE>" | |
headers = {"Authorization": f"Bearer {hf_token}"} | |
# Directory to save and extract files |
This file contains 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
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 |
This file contains 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 | |
x = np.random.randn(3,3) | |
x_tensor = torch.from_numpy(x) | |
dropout = torch.nn.Dropout(0.5) | |
dropout(x_tensor) |
This file contains 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
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 | |
This file contains 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 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) |
This file contains 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
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() |
This file contains 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
x = torch.randn(1, 3, 224, 224).uniform_(0, 1) | |
alexnet = AlexNet() | |
alexnet(x).size() |
This file contains 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
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), |
This file contains 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.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 | |
NewerOlder