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 sympy as sym | |
x1, x2 = sym.symbols("x1 x2") | |
coord = [x1, x2] | |
g = sym.Matrix([[1,0],[0,x1**2]]) | |
ginv = g.inv() | |
def christoffel(coord, g, ginv, index1, index2, index3): | |
""" | |
coord is the list of coordinates, eg coord = [r, theta, phi] |
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 feed_forward(self,x): | |
""" | |
Calculate the value(s) of the neural net at the output level. | |
""" | |
y_guess = self.act(T.dot(x,self.W[0])+ self.b[0]) | |
for i in xrange(1,len(self.W)): | |
W = self.W[i] | |
b = self.b[i] | |
if i == len(self.W)-1: | |
y_guess = T.nnet.softmax(T.dot(y_guess,W)+b) |
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
void loop() { | |
randNumber1 = random(0,100); | |
randNumber2 = random(0,100); | |
int bigger; | |
if (randNumber1 > randNumber2){ | |
bigger = 1; | |
}else{ | |
bigger = 0; | |
} | |
while (digitalRead(pin_in1) == HIGH){ |
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
""" | |
Took the main functionality of this code from https://www.lebsanft.org/?p=48 | |
""" | |
import serial | |
import matplotlib | |
matplotlib.use('TkAgg') | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import time | |
import sys |
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
/* | |
Random Squares, originally by Bill Kolomyjec | |
*/ | |
int max_sqrs = 9 ; | |
int large_sqr_dim = 7; | |
int sqr_dim ; //= width / 7 ; | |
int init_sqr_dim ; // = sqr_dim / 5 ; | |
boolean zero_sqr = false; |
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
-- building the MLP | |
net = nn.Sequential() | |
net:add(nn.Linear(150,400)) | |
net:add(nn.Linear(400,300)) | |
net:add(nn.Linear(300,200)) | |
net:add(nn.Tanh()) -- tanh squashing function | |
net:add(nn.Linear(200,2)) | |
net:add(nn.LogSoftMax()) | |
-- Training the net |
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
from PyQt4 import QtCore, QtGui | |
from mainui import MainUI | |
import time | |
from hardware_controller import Hardware_Controller | |
class Worker(QtCore.QThread): | |
update_text_signal = QtCore.pyqtSignal(str) #have to pass the type str | |
def __init__(self, hdwr_ctrl, update_rate): |
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
function Array2D(...) | |
local args = {...} | |
if #args == 0 then | |
args = {{{}}} | |
end | |
local array2d = { | |
__index = self, | |
vals = args[1], | |
shape = {#args[1], #args[1][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
import theano | |
import theano.tensor as T | |
import numpy as np | |
import h5py | |
import os | |
import time | |
def rungekuttastep(h,y,fprime,*args): | |
k1 = h*fprime(y,*args) |
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 time | |
import pdb | |
import numpy as np | |
import theano | |
import theano.tensor as T | |
import h5py | |
class LSTMLayer(object): |