-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_models.py
More file actions
31 lines (23 loc) · 810 Bytes
/
test_models.py
File metadata and controls
31 lines (23 loc) · 810 Bytes
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
import numpy as np
import cPickle as cp
import theano
import theano.tensor as T
import time
#from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from theano.tensor.shared_randomstreams import RandomStreams
from models import LinearGaussian as Lmodel
from matplotlib import pyplot as pp
inputdims=2
outputdims=4
log_stddev=np.random.randn(outputdims)
model=Lmodel(inputdims,outputdims)
model.M.set_value(np.zeros((inputdims, outputdims)).astype(np.float32))
model.log_stddev.set_value(log_stddev.astype(np.float32))
inputsamps=T.fmatrix()
samps, probs = model.get_samples(inputsamps)
sample=theano.function([inputsamps],[samps, probs],allow_input_downcast=True)
s=np.zeros((10000,2))
samples, log_probs = sample(s)
var=np.mean(samples**2,axis=0)
print var
print np.exp(2.0*log_stddev)