/
run_model.py
37 lines (33 loc) · 897 Bytes
/
run_model.py
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
import theano
import theano.tensor as T
import numpy as np
from theano_toolkit.parameters import Parameters
from theano_toolkit import updates
from theano_toolkit import utils as U
from theano_toolkit import hinton
import controller
import model
import tasks
import random
import math
def make_model(
input_size=8,
output_size=8,
mem_size=128,
mem_width=20,
hidden_size=100):
"""
Given the model parameters, return a Theano function for the NTM's model
"""
P = Parameters()
# Build the controller
ctrl = controller.build(P,input_size,output_size,mem_size,mem_width,hidden_size)
predict = model.build(P,mem_size,mem_width,hidden_size,ctrl)
input_seq = T.matrix('input_sequence')
[M_curr,weights,output] = predict(input_seq)
# Return a Theano function for the NTM
test_fun = theano.function(
inputs=[input_seq],
outputs=[weights,output]
)
return P,test_fun