In [1]:
%pylab inline
In [2]:
import sys
sys.version
sys.path += ["/usr/local/lib/python2.7/dist-packages"]
In [3]:
import clstm
import numpy
In [4]:
inputs = clstm.Sequence()
outputs = clstm.Sequence()
targets = clstm.Sequence()
In [5]:
a = array(randn(100,11,7),'f')
clstm.sequence_of_array(inputs,a)
print inputs.size(), inputs.depth(), inputs.batchsize()
#clstm.array_of_sequence(b,inputs)
#print b.shape
In [6]:
b = numpy.empty_like(a)
clstm.array_of_sequence(b,inputs)
In [7]:
b = numpy.empty((1,1,1),'f')
clstm.array_of_sequence(b,inputs)
b.shape
Out[7]:
In [8]:
net = clstm.make_net_init("bidi","ninput=11:nhidden=20:noutput=13")
net
Out[8]:
In [9]:
print clstm.network_info(net)
In [10]:
temp = clstm.make_layer("LSTM")
temp
In [11]:
clstm.sequence_of_array(net.inputs, a)
print net.inputs.size(), net.inputs.depth(), net.inputs.batchsize()
In [12]:
print net.outputs.size(), net.outputs.depth(), net.outputs.batchsize()
net.forward()
print net.outputs.size(), net.outputs.depth(), net.outputs.batchsize()
In [13]:
deltas = zeros(0,'f')
clstm.array_of_sequence(deltas,net.outputs)
deltas *= 0
clstm.sequence_of_array(net.d_outputs,deltas)
In [14]:
print net.d_inputs.size(), net.d_inputs.depth(), net.d_inputs.batchsize()
net.backward()
print net.d_inputs.size(), net.d_inputs.depth(), net.d_inputs.batchsize()
In [ ]: