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 os | |
| # os.environ["THEANO_FLAGS"] = "mode=FAST_RUN,device=gpu,floatX=float32" | |
| # import theano | |
| # import the neural net stuff | |
| from keras.models import Sequential | |
| from keras import optimizers | |
| from keras.layers.core import Dense, Dropout, Activation, Flatten | |
| from keras.layers.convolutional import Convolution1D | |
| from keras.layers.normalization import BatchNormalization |
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
| # Euclidean distance. | |
| def euc_dist(pt1,pt2): | |
| return math.sqrt((pt2[0]-pt1[0])*(pt2[0]-pt1[0])+(pt2[1]-pt1[1])*(pt2[1]-pt1[1])) | |
| def _c(ca,i,j,P,Q): | |
| if ca[i,j] > -1: | |
| return ca[i,j] | |
| elif i == 0 and j == 0: | |
| ca[i,j] = euc_dist(P[0],Q[0]) | |
| elif i > 0 and j == 0: |