def testing_multiple_datasets_in_monitor_based_lr():
    # tests that the class MonitorBasedLRAdjuster in sgd.py does not take
    # multiple datasets in which multiple channels ending in '_objective'
    # exist.
    # This case happens when the user has not specified either channel_name or
    # dataset_name in the constructor

    dim = 3
    m = 10

    rng = np.random.RandomState([6, 2, 2014])

    X = rng.randn(m, dim)
    Y = rng.randn(m, dim)

    learning_rate = 1e-2
    batch_size = 5

    # We need to include this so the test actually stops running at some point
    epoch_num = 1

    # including a monitoring datasets lets us test that
    # the monitor works with supervised data
    monitoring_train = DenseDesignMatrix(X=X)
    monitoring_test = DenseDesignMatrix(X=Y)

    cost = DummyCost()

    model = SoftmaxModel(dim)

    dataset = DenseDesignMatrix(X=X)

    termination_criterion = EpochCounter(epoch_num)

    algorithm = SGD(learning_rate,
                    cost,
                    batch_size=batch_size,
                    monitoring_batches=2,
                    monitoring_dataset={'train': monitoring_train,
                                        'test': monitoring_test},
                    termination_criterion=termination_criterion,
                    update_callbacks=None,
                    set_batch_size=False)

    monitor_lr = MonitorBasedLRAdjuster()

    train = Train(dataset,
                  model,
                  algorithm,
                  save_path=None,
                  save_freq=0,
                  extensions=[monitor_lr])

    try:
        train.main_loop()
    except __HOLE__:
        return

    raise AssertionError("MonitorBasedLRAdjuster takes multiple dataset names "
                         "in which more than one \"objective\" channel exist "
                         "and the user has not specified either channel_name "
                         "or database_name in the constructor to "
                         "disambiguate.")
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/training_algorithms/tests/test_sgd.py/testing_multiple_datasets_in_monitor_based_lr