This file contains hidden or 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 java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
public class Main { | |
public static void main(String[] args) { | |
List<Long> times = new ArrayList<>(); | |
int numExperiments = 20; | |
long[] totals = new long[numExperiments]; | |
Random random = new Random(); |
This file contains hidden or 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 | |
from time import time | |
num_experiments = 20 | |
totals = np.zeros(num_experiments) | |
for i in range(num_experiments): | |
start = time() | |
arr = np.random.randint(0, 1000, size=100000000, dtype=np.int32) | |
print('Generation took ', time() - start) | |
start = time() |
This file contains hidden or 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 tensorflow as tf | |
def tf_repeat(tensor, repeats, axis): | |
shape = tf.shape(tensor) | |
axis_range = tf.range(shape.shape[0].value) | |
ones = tf.ones_like(axis_range) | |
repeats_tiled = tf.fill(tf.shape(axis_range), repeats) | |
axis_tiled = tf.fill(tf.shape(axis_range), axis) | |
mask = tf.equal(axis_range, axis_tiled) |
This file contains hidden or 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 sys | |
signs_map = { | |
'>': 1, | |
'<': -1, | |
'_': 0 | |
} | |
reverse_signs_map = { | |
0: '_', |
This file contains hidden or 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
0.9::attribute_value(brown, brand). | |
0.9::attribute_value(brown, color). | |
0.9::attribute_value(tv, noun). | |
0.9::attribute_value(dress, clothing). | |
member(X, [Y|T]) :- X = Y; member(X, T). | |
item_prop(1, brown, brand). | |
item_prop(1, tv, noun). |
This file contains hidden or 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
package config; | |
import java.io.File; | |
import java.io.IOException; | |
import org.junit.Test; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.chrome.ChromeDriverService; |
This file contains hidden or 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 pickled data | |
import pickle | |
import os.path | |
import os | |
import wget | |
import cv2 | |
import zipfile | |
import numpy as np | |
This file contains hidden or 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 longestPalindrome(self, s): | |
""" | |
:type s: str | |
:rtype: str | |
""" | |
best_palindrome_length = 1 | |
best_palindrome = s[0] | |
n = len(s) | |
for i in range(2 * n - 1): |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
import numpy as np | |
# Read in the image and print out some stats | |
# Note: in the previous example we were reading a .jpg | |
# Here we read a .png and convert to 0,255 bytescale | |
image = (mpimg.imread('test.png')*255).astype('uint8') | |
print('This image is: ',type(image), | |
'with dimensions:', image.shape) |
This file contains hidden or 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
% Hidden Markov Model example | |
% The weather can be in state "sun" or "rain" initially | |
% with 0.5 probabilities for each state | |
0.5::start(weather, sun); | |
0.5::start(weather, rain). | |
% In a given moment in time, if today is sunny - "sun", | |
% tommorrow will be 0.6 sun or 0.4 rain | |
0.6::trans(weather, Moment_in_time, sun, sun); |
NewerOlder