aboutsummaryrefslogtreecommitdiffstats
path: root/simulation/vi_blocks.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2015-12-02 16:30:37 -0500
committerThibaut Horel <thibaut.horel@gmail.com>2015-12-02 16:30:37 -0500
commit0fc1aa731e26683d21ed1a91f56d047d1682fd7e (patch)
treec80ad05a80b8aab39f917495ce5aeb2e01ea5dad /simulation/vi_blocks.py
parent0e90119296f6bbbaf28fbaa329556d6d9cd86f3f (diff)
downloadcascades-0fc1aa731e26683d21ed1a91f56d047d1682fd7e.tar.gz
Fix errors computation
Diffstat (limited to 'simulation/vi_blocks.py')
-rw-r--r--simulation/vi_blocks.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/simulation/vi_blocks.py b/simulation/vi_blocks.py
index 50c7fb1..e2e3bd9 100644
--- a/simulation/vi_blocks.py
+++ b/simulation/vi_blocks.py
@@ -26,7 +26,7 @@ def create_vi_model(n_nodes, n_samp=100):
"""return variational inference theano computation graph"""
def aux(a, b):
rand = a + b * np.random.normal(size=(n_nodes, n_nodes))
- return np.clip(rand, 1e-3, 1 - 1e-3).astype(theano.config.floatX)
+ return np.clip(rand, 1e-10, 1000).astype(theano.config.floatX)
x = tsr.matrix(name='x', dtype='int8')
s = tsr.matrix(name='s', dtype='int8')
@@ -54,12 +54,14 @@ if __name__ == "__main__":
batch_size = 100
freq = 10
graph = utils.create_wheel(1000)
+ g_shared = theano.shared(value=graph, name='graph')
n_samples = 50
- #graph = utils.create_random_graph(n_nodes=10)
+ # graph = utils.create_random_graph(n_nodes=10)
print('GRAPH:\n', graph, '\n-------------\n')
x, s, mu, sig, cost = create_vi_model(len(graph), n_samples)
- rmse = ub.rmse_error(graph, mu)
+ rmse = ub.rmse_error(g_shared, mu)
+ error = ub.absolute_error(g_shared, mu)
step_rules = algorithms.CompositeRule([algorithms.AdaDelta(),
ClippedParams(1e-3, 1000)])
@@ -72,11 +74,12 @@ if __name__ == "__main__":
log_backend="sqlite",
extensions=[
be.FinishAfter(after_n_batches=10**3),
- bm.TrainingDataMonitoring([cost, rmse, mu], every_n_batches=freq),
+ bm.TrainingDataMonitoring([cost, rmse, mu, error],
+ every_n_batches=freq),
be.Printing(every_n_batches=freq, after_epoch=False),
ub.JSONDump("logs/nonactive_vi.json", every_n_batches=freq),
- #ub.ActiveLearning(dataset=data_stream.dataset, params=graph,
- #every_n_batches=freq)
+ # ub.ActiveLearning(dataset=data_stream.dataset, params=graph,
+ # every_n_batches=freq)
]
)
loop.run()