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 | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class Net(nn.Module): | |
def __init__(self, weight): | |
super(Net, self).__init__() | |
# initializes the weights of the convolutional layer to be the weights of the 4 defined filters |
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 numpy as np | |
print("Enter the two values for input layers") | |
print('a = ') | |
a = int(input()) | |
# 2 | |
print('b = ') | |
b = int(input()) | |
# 3 |
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 gym | |
from time import sleep | |
# Creating thr env | |
env = gym.make("Taxi-v2").env | |
env.s = 328 | |
# Setting the number of iterations, penalties and reward to zero, |
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
# Importing Modules | |
from sklearn.datasets import load_iris | |
import matplotlib.pyplot as plt | |
from sklearn.cluster import DBSCAN | |
from sklearn.decomposition import PCA | |
# Load Dataset | |
iris = load_iris() | |
# Declaring Model |
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
# Importing Modules | |
from sklearn import datasets | |
import matplotlib.pyplot as plt | |
# Loading dataset | |
iris_df = datasets.load_iris() | |
# Available methods on dataset | |
print(dir(iris_df)) |
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 cv2 | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
img_path = 'dog.jpg' | |
bgr_img = cv2.imread(img_path) | |
gray_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2GRAY) | |
# Normalise |
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
viz_layer(activated_layer) | |
viz_layer(pooled_layer) |
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 viz_layer(layer, n_filters= 4): | |
fig = plt.figure(figsize=(20, 20)) | |
for i in range(n_filters): | |
ax = fig.add_subplot(1, n_filters, i+1) | |
ax.imshow(np.squeeze(layer[0,i].data.numpy()), cmap='gray') | |
ax.set_title('Output %s' % str(i+1)) | |
fig = plt.figure(figsize=(12, 6)) | |
fig.subplots_adjust(left=0, right=1.5, bottom=0.8, top=1, hspace=0.05, wspace=0.05) |
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 numpy as np | |
filter_vals = np.array([ | |
[-1, -1, 1, 1], | |
[-1, -1, 1, 1], | |
[-1, -1, 1, 1], | |
[-1, -1, 1, 1] | |
]) | |
print('Filter shape: ', filter_vals.shape) |
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
img = np.squeeze(images[7]) | |
fig = plt.figure(figsize = (12,12)) | |
ax = fig.add_subplot(111) | |
ax.imshow(img, cmap='gray') | |
width, height = img.shape | |
thresh = img.max()/2.5 | |
for x in range(width): | |
for y in range(height): | |
val = round(img[x][y],2) if img[x][y] !=0 else 0 |
NewerOlder