Blame view
SPE_mlp.py
2.57 KB
b6d0165d1 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# coding: utf-8 # In[29]: # Import import itertools import shelve import pickle import pandas import numpy import nltk import codecs import gensim import scipy from scipy import sparse import scipy.sparse import scipy.io import sklearn from sklearn.feature_extraction.text import CountVectorizer import sklearn.metrics from sklearn.neighbors import NearestNeighbors from sklearn.metrics import confusion_matrix from sklearn import preprocessing from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation,AutoEncoder from keras.optimizers import SGD from keras.layers import containers from mlp import * import mlp # In[3]: # In[4]: #db=shelve.open("SPELIKE_MLP_DB.shelve",writeback=True) corps=shelve.open("DECODA_SPE_V2.shelve") # [ TRS_SPELIKE_H2_RELU', 'ASR_SPELIKE_OUT_RELU', 'ASR_SPELIKE_H2_RELU' ] sparse_corps=shelve.open("DECODA_sparse.shelve") # [ 'vocab', 'LABEL', 'TRS_SPARSE', 'ASR_SPARSE'] out_db=shelve.open("scores/MLP_SPE_V2.shelve",writeback=True) # In[ ]: out_db["ASR_SPARSE"]=mlp.train_mlp(sparse_corps["ASR_SPARSE"]["TRAIN"].todense(),sparse_corps["LABEL"]["TRAIN"],sparse_corps["ASR_SPARSE"]["DEV"].todense(),sparse_corps["LABEL"]["DEV"],sparse_corps["ASR_SPARSE"]["TEST"].todense(),sparse_corps["LABEL"]["TEST"],[1024,512,1024],dropouts=[0.5,0.25,0],sgd="adam",epochs=150) out_db["TRS_SPARSE"]=mlp.train_mlp(sparse_corps["TRS_SPARSE"]["TRAIN"].todense(),sparse_corps["LABEL"]["TRAIN"],sparse_corps["TRS_SPARSE"]["DEV"].todense(),sparse_corps["LABEL"]["DEV"],sparse_corps["TRS_SPARSE"]["TEST"].todense(),sparse_corps["LABEL"]["TEST"],[1024,512,1024],dropouts=[0.5,0.25,0],sgd="adam",epochs=150) out_db["ASR_AEOUT_SPARSE"]=mlp.train_mlp(corps["ASR_SPELIKE_OUT_RELU"]["TRAIN"],sparse_corps["LABEL"]["TRAIN"],corps["ASR_SPELIKE_OUT_RELU"]["DEV"],sparse_corps["LABEL"]["DEV"],corps["ASR_SPELIKE_OUT_RELU"]["TEST"],sparse_corps["LABEL"]["TEST"],[1024,512,1024],dropouts=[0.5,0.25,0],sgd="adam",epochs=150) out_db["ASR_AEH2_SPARSE"]=mlp.train_mlp(corps["ASR_SPELIKE_H2_RELU"]["TRAIN"],sparse_corps["LABEL"]["TRAIN"],corps["ASR_SPELIKE_H2_RELU"]["DEV"],sparse_corps["LABEL"]["DEV"],corps["ASR_SPELIKE_H2_RELU"]["TEST"],sparse_corps["LABEL"]["TEST"],[1024,512,1024],dropouts=[0.5,0.25,0],sgd="adam",epochs=150) out_db["TRS_AEH2_SPARSE"]=mlp.train_mlp(corps["TRS_SPELIKE_H2_RELU"]["TRAIN"],sparse_corps["LABEL"]["TRAIN"],corps["TRS_SPELIKE_H2_RELU"]["DEV"],sparse_corps["LABEL"]["DEV"],corps["TRS_SPELIKE_H2_RELU"]["TEST"],sparse_corps["LABEL"]["TEST"],[1024,512,1024],dropouts=[0.5,0.25,0],sgd="adam",epochs=150) corps.close() sparse_corps.close() out_db.close() |