From 0fc1aa731e26683d21ed1a91f56d047d1682fd7e Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Wed, 2 Dec 2015 16:30:37 -0500 Subject: Fix errors computation --- simulation/vi_blocks.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'simulation/vi_blocks.py') 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() -- cgit v1.2.3-70-g09d2