Skip to content

Instantly share code, notes, and snippets.

🦂
you might find something interesting here

Vihar Kurama vihar

🦂
you might find something interesting here
View GitHub Profile
View step_5_cnns.py
viz_layer(activated_layer)
viz_layer(pooled_layer)
View step_4_cnns.py
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)
View step_3_cnns.py
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
View step_2_cnns.py
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)
View step_1_cnns.py
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
View single_image.py
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
View mnist_image.py
# Load the libraries
import torch
import numpy as np
from torchvision import datasets
import torchvision.transforms as transforms
# Set the parameters
num_workers = 0
batch_size = 20
View JS-Questions.md

Caravel.AI Intern Interview 2018

  • Write a code snippet about how this works in JavaScript and explain it.

  • Write a code snippet explaining forEach and map methods in JavaScript. Make your examples as creative as possible.

  • Write a code snippet which takes in an E-mail from the user and validates it using a regular expression. The Email should start with the letter c and end with @caravel.ai(domain). It can contain three numbers at the end. The email should not exceed ten letters.

  • Create a box in HTML with a gradient background color, whenever the page reloads the background color should be changing.

View Caravel-Interview-2018.md

Caravel.AI Intern Interview 2018

  • Write a code snippet about how this works in JavaScript and explain it. Your code should be restricted to 5 or 6 lines.

  • Write about how synchronisation works in Java in two sentences with a code snippet.

  • Write how you can build a website in 5 steps, your steps should include the name of the step(a creative one), little description(should be restricted to 3 sentences) and also code snippet. Your entire code snippet website code should not be more than 30 lines of code.

  • What is JSON? Explain in detail, and write a small snippet in Python to generate a JSON type object for given string and explain the process.

View q-learning.py
import gym
import numpy as np
import random
from IPython.display import clear_output
# Init Taxi-V2 Env
env = gym.make("Taxi-v2").env
# Init arbitary values
q_table = np.zeros([env.observation_space.n, env.action_space.n])
You can’t perform that action at this time.