-
Write a code snippet about how
this
works in JavaScript and explain it. -
Write a code snippet explaining
forEach
andmap
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.- Examples: caravel127@caravel.ai, common@caravel.ai, cloud@caravel.ai
-
Create a box in HTML with a gradient background color, whenever the page reloads the background color should be changing.
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 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 | |
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
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
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 |
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
# 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 |
-
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.
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 | |
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]) |
NewerOlder