How to use the netron.solvers.RandomSearch.RandomSearch function in netron

To help you get started, we’ve selected a few netron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yankov / netron / netron / solvers / RandomSearch.py View on Github external
flat_params_grid = self.grid.create_flat_layers_grid(layers, input_shape, output_dim)
            for optimizer_name in self.grid.params_grid["optimizers"]:
                flat_grid = flat_params_grid.copy()
                flat_grid.update(self.grid.create_flat_optimizer_grid(optimizer_name))

                n_samples = min(self.params_sample_size, len(ParameterGrid(flat_grid)))
                for params in ParameterSampler(flat_grid, n_samples):
                    nn_params = self.grid.fold_params(params)
                    yield self.model_factory.create_model(layers, nn_params, loss_type)

# Example.
if __name__ == "__main__":
    import sys

    _, grid, layer_sample_num, param_sample_num = sys.argv
    job_stream = RandomSearch(grid, [1, 28, 28], 10, "keras", "sin_data.npz", int(param_sample_num), int(layer_sample_num))
    job = ""
    n = 0
    while "wait" not in job:
        job = job_stream.get_new_job(worker_id = 1)
        #print job
        n += 1
    print "%d networks" % n