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 rbm | |
import scipy | |
import cpickle | |
import numpy as np | |
''' | |
This implementation is based on the MovieLens 100k dataset, | |
available at http://grouplens.org/datasets/movielens/ | |
''' |
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 | |
import scipy | |
import scipy.io as sio | |
import os | |
from matplotlib import pyplot as plt | |
import matplotlib.image as mpimg | |
randomness_source = np.random.rand(1, 7000000) | |
report_calls_to_sample_bernoulli = False | |
plt.ion() |
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 | |
l = np.random.randint(0, 1000, 10).tolist() | |
b = {} | |
a = [] | |
max = 0 | |
for i in l: | |
if len(str(i)) > max: | |
max = len(str(i)) |
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 splitNum(Nd): | |
N = bin(Nd)[2:]+'0' | |
cant = 0 | |
d = {} | |
for i in range(0, len(N)-1): | |
if int(N[i]) == 1: | |
d[cant] = i | |
cant += 1 | |
a = list('0'*(len(N)-1)) | |
b = list(a) |
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 ip2bin(ip): | |
num = [int(n) for n in ip.split('.')] | |
bits = ['0'*(8-len(bin(n)[2:]))+bin(n)[2:] for n in num] | |
return ''.join(bits) | |
def bin2ip(bin): | |
ip = [str(int(bin[i:i+8], 2))+'.' for i in range(0, 32, 8)] | |
return ''.join(ip)[0:-1] |
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 eval_constraints(sq, n): | |
fitness = 0 | |
totalRowDiff = 0 | |
totalColDiff = 0 | |
rightDiagonal = 0 | |
leftDiagonal = 0 | |
for row in range(0, len(sq)): | |
sum_row = 0 | |
sum_col = 0 | |
for col in range(0, len(sq)): |
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
private static int[][] swap_values(int[][] sq, int times) | |
{ | |
int[][] temp_sq = (int[][]) sq.clone(); | |
Random rand = new Random(); | |
for(int i = 0; i < times; i++) | |
{ | |
r1 = rand.nextInt(len(sq)); | |
c1 = rand.nextInt(len(sq)); | |
r2 = rand.nextInt(len(sq)); | |
c2 = rand.nextInt(len(sq)); |
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 re | |
KEY_REGEX = '^[,]?["][a-zA-Z_][\w-]*["]$' | |
VALUE_REGEX = '^["].*["][,]?$' | |
CURLY_PAIR = ('{', '}') | |
SQ_PAIR = ('[', ']') | |
class JSONException(Exception): | |
def __init__(self, value): |
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
#include<math.h> | |
#define G 9.8 // m/s^2 | |
int analogPin = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} |
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
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
const char* byte_to_binary(int x) | |
{ | |
static char b[9]; | |
b[0] = '\0'; | |
int z; |
OlderNewer