From 5fbd4664e76d25de95f89329ee5f0f912fee4259 Mon Sep 17 00:00:00 2001 From: jeanpouget-abadie Date: Wed, 2 Dec 2015 12:31:05 -0500 Subject: frequency param introduced + plots_utils file sketch --- simulation/active_blocks.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'simulation/active_blocks.py') diff --git a/simulation/active_blocks.py b/simulation/active_blocks.py index 1495eb8..be1fc3d 100644 --- a/simulation/active_blocks.py +++ b/simulation/active_blocks.py @@ -43,7 +43,9 @@ class ActiveLearning(blocks.extensions.SimpleExtension): def do(self, which_callback, *args): out_degree = np.sum(self.dataset.graph, axis=1) self.dataset.node_p = out_degree / np.sum(out_degree) - print(self.dataset.node_p) + +# def do(self, which_callback, *args): + class JSONDump(blocks.extensions.SimpleExtension): @@ -149,7 +151,8 @@ def create_learned_data_stream(graph, batch_size): if __name__ == "__main__": batch_size = 100 n_obs = 1000 - graph = utils.create_wheel(10) + frequency = 1 + graph = utils.create_wheel(1000) print('GRAPH:\n', graph, '\n-------------\n') g_shared = theano.shared(value=graph, name='graph') @@ -160,17 +163,17 @@ if __name__ == "__main__": alg = algorithms.GradientDescent( cost=-cost, parameters=[params], step_rule=blocks.algorithms.AdaDelta() ) - # data_stream = create_learned_data_stream(graph, batch_size) - data_stream = create_fixed_data_stream(n_obs, graph, batch_size) + data_stream = create_learned_data_stream(graph, batch_size) + #data_stream = create_fixed_data_stream(n_obs, graph, batch_size) loop = main_loop.MainLoop( alg, data_stream, extensions=[ - be.FinishAfter(after_n_batches=10**3), - bm.TrainingDataMonitoring([cost, params, - rmse, error], every_n_batches=10), - be.Printing(every_n_batches=10), - JSONDump("log.json", every_n_batches=10) - # ActiveLearning(data_stream.dataset), + be.FinishAfter(after_n_batches=10**4), + bm.TrainingDataMonitoring([cost, rmse, error], + every_n_batches=frequency), + be.Printing(every_n_batches=frequency), + JSONDump("tmpactive_log.json", every_n_batches=frequency), + ActiveLearning(data_stream.dataset, every_n_batches=frequency) ], ) loop.run() -- cgit v1.2.3-70-g09d2