How to use the cortex.add_cost function in cortex

To help you get started, we’ve selected a few cortex 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 rdevon / BGAN / cont_mnist.py View on Github external
def build_normal_GAN():
    cortex.add_step('discriminator._cost', P='fake.P', X=0.,
                    name='fake_cost')
    cortex.add_step('discriminator._cost', P='real.P', X=1.,
                    name='real_cost')

    cortex.build()
    
    cortex.add_cost(
        lambda x, y: x + y, 'fake_cost.output', 'real_cost.output',
        name='discriminator_cost')
    
    m = 0
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
            cells=['discriminator'], name='generator_cost')
    else:
        raise

    cortex.add_stat('basic_stats', 'fake.P', name='fake_rate')
    cortex.add_stat('basic_stats', 'real.P', name='real_rate')
github rdevon / BGAN / cont_conv_mnist.py View on Github external
def build_normal_GAN():
    '''
    cortex.add_step('discriminator._cost', P='fake.P', X=0.,
                    name='fake_cost')
    cortex.add_step('discriminator._cost', P='real.P', X=1.,
                    name='real_cost')
    '''

    cortex.build()
    
    cortex.add_cost(
        disc_cost, 'real.P', 'fake.P',
        cells=['discriminator'],
        name='discriminator_cost')
    
    m = 2
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
github rdevon / BGAN / cont_conv_cifar.py View on Github external
def build_normal_GAN():
    cortex.add_step('discriminator._cost', P='fake.P', X=0.,
                    name='fake_cost')
    cortex.add_step('discriminator._cost', P='real.P', X=1.,
                    name='real_cost')

    cortex.build()
    
    cortex.add_cost(
        lambda x, y: x + y, 'fake_cost.output', 'real_cost.output',
        name='discriminator_cost')
    
    m = 2
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
            cells=['discriminator', 'baseline'], name='generator_cost')
github rdevon / BGAN / cont_mnist.py View on Github external
def build_wasserstein_GAN():
    cortex.build()
    cortex.add_cost(wasserman_cost_d, 'real.output', 'fake.output',
                    name='discriminator_cost')
    cortex.add_cost(wasserman_cost_g, 'fake.output',
                    name='generator_cost')
    cortex.add_stat('basic_stats', 'data.input')
github rdevon / BGAN / cont_mnist.py View on Github external
cortex.add_cost(
        lambda x, y: x + y, 'fake_cost.output', 'real_cost.output',
        name='discriminator_cost')
    
    m = 0
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
            cells=['discriminator'], name='generator_cost')
    else:
        raise

    cortex.add_stat('basic_stats', 'fake.P', name='fake_rate')
    cortex.add_stat('basic_stats', 'real.P', name='real_rate')
github rdevon / BGAN / discrete_mnist.py View on Github external
cortex.prepare_samples('noise', batch_size)
    cortex.add_step('generator', 'noise.samples', constants=['noise.samples'])
    cortex.prepare_samples('generator.P', n_posterior_samples)
    cortex.add_step('discriminator', 'generator.samples', name='fake',
                    constants=['generator.samples'])
    
    cortex.add_step('discriminator._cost', P='fake.P', X=0., name='fake_cost')
    cortex.add_step('discriminator._cost', P='real.P', X=1., name='real_cost')
    cortex.add_step('noise.grid2d', random_idx=True, name='noise_grid')
    cortex.add_step('generator', 'noise_grid.output', name='gen_grid')
    
    cortex.build()

    #cortex.add_cost('l2_decay', 0.002, 'discriminator.mlp.weights')
    cortex.add_cost('l2_decay', 0.002, 'generator.mlp.weights')
    
    cortex.add_cost(lambda x, y: x + y, 'fake_cost.output', 'real_cost.output',
                name='discriminator_cost')
    cortex.add_cost(reweighted_MLE, G='generator.P',
                    G_samples='generator.samples',
                    cells=['generator', 'discriminator'],
                    name='generator_cost')
    
    train_session = cortex.create_session()
    cortex.build_session(test=test)

    trainer = cortex.setup_trainer(
        train_session,
        optimizer='sgd',
        epochs=3000,
        learning_rate=0.01,
github rdevon / BGAN / cont_conv_mnist.py View on Github external
'''

    cortex.build()
    
    cortex.add_cost(
        disc_cost, 'real.P', 'fake.P',
        cells=['discriminator'],
        name='discriminator_cost')
    
    m = 2
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
            cells=['discriminator', 'baseline'], name='generator_cost')
    else:
        raise

    cortex.add_stat('basic_stats', 'fake.P', name='fake_rate')
    cortex.add_stat('basic_stats', 'real.P', name='real_rate')
github rdevon / BGAN / cont_conv_cifar.py View on Github external
cortex.add_step('discriminator._cost', P='real.P', X=1.,
                    name='real_cost')

    cortex.build()
    
    cortex.add_cost(
        lambda x, y: x + y, 'fake_cost.output', 'real_cost.output',
        name='discriminator_cost')
    
    m = 2
    if m == 0:
        cortex.add_cost(gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 1:    
        cortex.add_cost(alt_gen_cost, F='fake.P',
                        cells=['discriminator'],
                        name='generator_cost')
    elif m == 2:
        cortex.add_cost(
            reweighted_MLE, G_samples='generator.output',
            cells=['discriminator', 'baseline'], name='generator_cost')
    else:
        raise

    cortex.add_stat('basic_stats', 'fake.P', name='fake_rate')
    cortex.add_stat('basic_stats', 'real.P', name='real_rate')