How to use the polyaxon.experiments.Experiment function in polyaxon

To help you get started, we’ve selected a few polyaxon 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 polyaxon / polyaxon / tests / test_experiments / test_experiments.py View on Github external
def test_continuous_eval(self):
        for est in self._estimators_for_tests(eval_dict={'global_step': 100}):
            est.fake_checkpoint()
            noop_hook = _NoopHook()
            ex = Experiment(
                est,
                train_input_fn='train_input',
                eval_input_fn='eval_input',
                eval_hooks=[noop_hook],
                eval_delay_secs=0,
                continuous_eval_throttle_secs=0)
            self.assertRaises(StopIteration, ex.continuous_eval,
                              evaluate_checkpoint_only_once=False)
            self.assertEqual(0, est.fit_count)
            self.assertEqual(6, est.eval_count)
            self.assertEqual([noop_hook], est.eval_hooks)
github polyaxon / polyaxon / tests / test_experiments / test_experiments.py View on Github external
def test_continuous_eval_throttle_delay(self):
        for delay in [0, 1, 2]:
            for est in self._estimators_for_tests():
                est.fake_checkpoint()
                noop_hook = _NoopHook()
                ex = Experiment(
                    est,
                    train_input_fn='train_input',
                    eval_input_fn='eval_input',
                    eval_hooks=[noop_hook],
                    continuous_eval_throttle_secs=delay,
                    eval_delay_secs=0)
                sheep = SheepCounter()
                with test.mock.patch.object(time, 'time', sheep.time):
                    with test.mock.patch.object(time, 'sleep', sheep.sleep):
                        self.assertRaises(
                            StopIteration,
                            ex.continuous_eval,
                            evaluate_checkpoint_only_once=False)
                        self.assertAlmostEqual(5 * delay, sheep.time(), delta=1e-4)
github polyaxon / polyaxon / examples / programatic_examples / conv_highway_mnist.py View on Github external
def experiment_fn(output_dir):
    """Creates an experiment using cnn for MNIST dataset classification task."""
    dataset_dir = '../data/mnist'
    plx.datasets.mnist.prepare(dataset_dir)
    train_input_fn, eval_input_fn = plx.datasets.mnist.create_input_fn(dataset_dir)

    run_config = plx.configs.RunConfig(save_checkpoints_steps=100)
    experiment = plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(model_fn=model_fn, model_dir=output_dir,
                                           config=run_config),
        train_input_fn=train_input_fn,
        eval_input_fn=eval_input_fn,
        train_steps=1000,
        eval_steps=10,
        eval_every_n_steps=5)

    return experiment
github polyaxon / polyaxon / examples / programatic_examples / autoencoder.py View on Github external
def experiment_fn(output_dir):
    """Creates an auto encoder on MNIST handwritten digits.

    inks:
        * [MNIST Dataset] http://yann.lecun.com/exdb/mnist/
    """
    dataset_dir = '../data/mnist'
    plx.datasets.mnist.prepare(dataset_dir)
    train_data_file = plx.datasets.mnist.RECORD_FILE_NAME_FORMAT.format(
        dataset_dir, plx.Modes.TRAIN)
    eval_data_file = plx.datasets.mnist.RECORD_FILE_NAME_FORMAT.format(dataset_dir, plx.Modes.EVAL)
    meta_data_file = plx.datasets.mnist.META_DATA_FILENAME_FORMAT.format(dataset_dir)

    run_config = plx.estimators.RunConfig()
    experiment = plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(
            model_fn=model_fn, model_dir=output_dir, config=run_config),
        train_input_fn=get_input_fn(plx.Modes.TRAIN, train_data_file, meta_data_file),
        eval_input_fn=get_input_fn(plx.Modes.EVAL, eval_data_file, meta_data_file),
        train_steps=1000,
        eval_steps=10)

    return experiment
github polyaxon / polyaxon / examples / programatic_examples / alexnet_flowers17.py View on Github external
References:
        * Alex Krizhevsky, Ilya Sutskever & Geoffrey E. Hinton. ImageNet Classification with
        Deep Convolutional Neural Networks. NIPS, 2012.
        * 17 Category Flower Dataset. Maria-Elena Nilsback and Andrew Zisserman.

    Links:
        * [AlexNet Paper](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf)  # noqa
        * [Flower Dataset (17)](http://www.robots.ox.ac.uk/~vgg/data/flowers/17/)
    """
    dataset_dir = '../data/flowers17'
    plx.datasets.flowers17.prepare(dataset_dir)
    train_input_fn, eval_input_fn = plx.datasets.flowers17.create_input_fn(dataset_dir)

    run_config = plx.estimators.RunConfig().replace(save_checkpoints_steps=100)
    experiment = plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(model_fn=model_fn,
                                           model_dir=output_dir,
                                           config=run_config),
        train_input_fn=train_input_fn,
        eval_input_fn=eval_input_fn,
        train_steps=1000,
        eval_steps=10)

    return experiment
github polyaxon / polyaxon / examples / programatic_examples / vgg19.py View on Github external
def experiment_fn(output_dir):
    """Creates an experiement using a VGG19 to mnist Dataset.

    References:
        * Very Deep Convolutional Networks for Large-Scale Image Recognition.
        K. Simonyan, A. Zisserman. arXiv technical report, 2014.

    Links:
        * http://arxiv.org/pdf/1409.1556
    """
    dataset_dir = '../data/mnist'
    plx.datasets.mnist.prepare(dataset_dir)
    train_input_fn, eval_input_fn = plx.datasets.mnist.create_input_fn(dataset_dir)
    experiment = plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(model_fn=model_fn, model_dir=output_dir),
        train_input_fn=train_input_fn,
        eval_input_fn=eval_input_fn,
        train_steps=10000,
        eval_steps=10)

    return experiment
github polyaxon / polyaxon / examples / programatic_examples / timeseries.py View on Github external
x = plx.layers.LSTM(units=num_units)(x)
        return plx.layers.Dense(units=output_units)(x)

    def model_fn(features, labels, mode):
        return plx.models.Regressor(
            mode=mode,
            graph_fn=graph_fn,
            loss=MeanSquaredErrorConfig(),
            optimizer=AdagradConfig(learning_rate=0.1),
            metrics=[
                RootMeanSquaredErrorConfig(),
                MeanAbsoluteErrorConfig()
            ]
        )(features=features, labels=labels)

    return plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(model_fn=model_fn, model_dir=output_dir),
        train_input_fn=plx.processing.numpy_input_fn(
            x={'x': x['train']}, y=y['train'], batch_size=64, num_epochs=None, shuffle=False),
        eval_input_fn=plx.processing.numpy_input_fn(
            x={'x': x['train']}, y=y['train'], batch_size=32, num_epochs=None, shuffle=False),
        train_steps=train_steps,
        eval_steps=10)
github polyaxon / polyaxon / examples / programatic_examples / variational_autoencoder_mnist.py View on Github external
def experiment_fn(output_dir, x_train, y_train, x_eval, y_eval):
    """Creates a variational auto encoder on MNIST handwritten digits.

    inks:
        * [MNIST Dataset] http://yann.lecun.com/exdb/mnist/
    """
    return plx.experiments.Experiment(
        estimator=plx.estimators.Estimator(model_fn=model_fn, model_dir=output_dir),
        train_input_fn=plx.processing.numpy_input_fn(
            x=x_train, y=y_train, batch_size=64, num_epochs=None, shuffle=False),
        eval_input_fn=plx.processing.numpy_input_fn(
            x=x_eval, y=y_eval, batch_size=32, num_epochs=None, shuffle=False),
        train_steps=5000,
        eval_steps=100)