Exemple #1
0
def test_meansquarederror():
    confs = itertools.product(batch_sizes, n_ins)
    for batch_size, n_in in confs:
        print('MeanSquaredError: batch_size=%i, n_in=%i' % (batch_size, n_in))
        x_shape = (batch_size, n_in)
        x = np.random.normal(size=x_shape)
        y = np.random.normal(size=x_shape)
        loss = dp.MeanSquaredError()
        loss._setup(x_shape)
        assert loss.loss(ca.array(x), ca.array(y)).shape == x_shape[:1]
        check_grad(loss, x, y)
                             weight_decay=0.004,
                             monitor=True),
    ),
    dp.Activation('relu'),
    dp.Pool(**pool_kwargs),
    dp.Convolutional(
        n_filters=64,
        filter_shape=(5, 5),
        border_mode='same',
        weights=dp.Parameter(dp.NormalFiller(sigma=0.01),
                             weight_decay=0.004,
                             monitor=True),
    ),
    dp.Activation('relu'),
    dp.Pool(**pool_kwargs),
    dp.Flatten(),
    dp.FullyConnected(
        n_output=64,
        weights=dp.Parameter(dp.NormalFiller(sigma=0.1),
                             weight_decay=0.004,
                             monitor=True),
    ),
    dp.Activation('relu'),
    dp.FullyConnected(
        n_output=6,
        weights=dp.Parameter(dp.NormalFiller(sigma=0.1),
                             weight_decay=0.004,
                             monitor=True),
    ),
    dp.MeanSquaredError(),
], )