

def test_train_supervised():
    '\n    Train a supervised GSN.\n    '
    gsn = GSN.new(layer_sizes=[ds.X.shape[1], 1000, ds.y.shape[1]], activation_funcs=['sigmoid', 'tanh', rescaled_softmax], pre_corruptors=([GaussianCorruptor(0.5)] * 3), post_corruptors=[SaltPepperCorruptor(0.3), None, SmoothOneHotCorruptor(0.5)], layer_samplers=[BinomialSampler(), None, MultinomialSampler()], tied=False)
    _rcost = MeanBinaryCrossEntropy()
    reconstruction_cost = (lambda a, b: (_rcost.cost(a, b) / ds.X.shape[1]))
    _ccost = MeanBinaryCrossEntropy()
    classification_cost = (lambda a, b: (_ccost.cost(a, b) / ds.y.shape[1]))
    c = GSNCost([(0, 1.0, reconstruction_cost), (2, 2.0, classification_cost)], walkback=WALKBACK, mode='supervised')
    alg = SGD(LEARNING_RATE, init_momentum=MOMENTUM, cost=c, termination_criterion=EpochCounter(MAX_EPOCHS), batches_per_iter=BATCHES_PER_EPOCH, batch_size=BATCH_SIZE, monitoring_dataset=ds, monitoring_batches=10)
    trainer = Train(ds, gsn, algorithm=alg, save_path='gsn_sup_example.pkl', save_freq=10, extensions=[MonitorBasedLRAdjuster()])
    trainer.main_loop()
    print('done training')

dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/gsn_example.py test_train_supervised/original