%pylab inline
Populating the interactive namespace from numpy and matplotlib
import sys
sys.version
sys.path += ["/usr/local/lib/python2.7/dist-packages"]
import clstm
import numpy
inputs = clstm.Sequence()
outputs = clstm.Sequence()
targets = clstm.Sequence()
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
100 11 7
b = numpy.empty_like(a)
clstm.array_of_sequence(b,inputs)
b = numpy.empty((1,1,1),'f')
clstm.array_of_sequence(b,inputs)
b.shape
(100, 11, 7)
net = clstm.make_net_init("bidi","ninput=11:nhidden=20:noutput=13")
net
<clstm.INetwork; proxy of <Swig Object of type 'std::shared_ptr< INetwork > *' at 0x7fbbba8e8c30> >
print clstm.network_info(net)
.Stacked: 0.000100 0.900000 11 13 .Stacked.Parallel: 0.000100 0.900000 11 40 .Stacked.Parallel.NPLSTM_SigmoidTanhTanh: 0.000100 0.900000 11 20 .Stacked.Parallel.Reversed: 0.000100 0.900000 11 20 .Stacked.Parallel.Reversed.NPLSTM_SigmoidTanhTanh: 0.000100 0.900000 11 20 .Stacked.SoftmaxLayer: 0.000100 0.900000 40 13
temp = clstm.make_layer("LSTM")
temp
clstm.sequence_of_array(net.inputs, a)
print net.inputs.size(), net.inputs.depth(), net.inputs.batchsize()
100 11 7
print net.outputs.size(), net.outputs.depth(), net.outputs.batchsize()
net.forward()
print net.outputs.size(), net.outputs.depth(), net.outputs.batchsize()
0 -1 -1 100 13 7
deltas = zeros(0,'f')
clstm.array_of_sequence(deltas,net.outputs)
deltas *= 0
clstm.sequence_of_array(net.d_outputs,deltas)
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()
0 -1 -1 100 11 7