#Load the preprocessed version, saving on computation
X = np.load('../data/data_cmu.npz')['clips']
X = np.swapaxes(X, 1, 2).astype(theano.config.floatX)
X = X[:,:-4]

preprocess = np.load('../data/Joe/preprocess.npz')
X = (X - preprocess['Xmean']) / preprocess['Xstd']

H = np.load('../data/Joe/HiddenActivations.npz')['Orig']


from network import network
network.load([
    None,
    '../models/conv_ae/layer_0.npz', None, None,
    '../models/conv_ae/layer_1.npz', None, None,
    '../models/conv_ae/layer_2.npz', None, None,
])

for layer in network.layers:
    if isinstance(layer, NoiseLayer): layer.amount = 0.0
    if isinstance(layer, Pool1DLayer):  layer.depooler = lambda x, **kw: x/2


# Go through inputs 1by1
for input in range(len(X)):

    Xorig = X[input:input+1]

    #Theano shared object to pass to network
    shared = theano.shared(H[input:input+1])
Exemple #2
0
X = np.load('../data/data_cmu.npz')['clips']
X = np.swapaxes(X, 1, 2).astype(theano.config.floatX)
X = X[:, :-4]

preprocess = np.load('../data/Joe/preprocess.npz')
X = (X - preprocess['Xmean']) / preprocess['Xstd']

from network import network

network.load([
    None,
    '../models/conv_ae/layer_0.npz',
    None,
    None,
    '../models/conv_ae/layer_1.npz',
    None,
    None,
    '../models/conv_ae/layer_2.npz',
    None,
    None,
])

for layer in network.layers:
    if isinstance(layer, NoiseLayer): layer.amount = 0.0
    if isinstance(layer, Pool1DLayer): layer.depooler = lambda x, **kw: x / 2

while True:

    index = rng.randint(len(X) - 1)
    amount = 0.5
Exemple #3
0
def test(X,y):
    global model 
    accuracies = []
    costs = []
    for i in range(0,X.shape[0],64):
        end = min(i+64,X.shape[0])
        model.test(X[i:end],y[i:end],accuracies,costs)
    
    accuracies = np.array(accuracies)
    costs = np.array(costs)
    print("Accuracy : ",np.mean(accuracies))
    print("Cost : ",np.sum(costs))
    
if __name__ == "__main__":
    global model
    model = network.load("model.json")

    data = json.load(open("data/data.json","rb"))

    trainX = np.array(data['trainX'])
    trainY = np.array(data['trainY'],dtype=np.int32)
    validX = np.array(data['validX'])
    validY = np.array(data['validY'],dtype=np.int32)
    testX = np.array(data['testX'])
    testY = np.array(data['testY'],dtype=np.int32)

    print("TRAIN SET")
    test(trainX,trainY)
    print("\n\nVALIDATION SET")
    test(validX,validY)
    print("\n\nTEST SET")