test_convolutional.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:keras 作者: NVIDIA 项目源码 文件源码
def test_deconvolution_2d():
    nb_samples = 2
    nb_filter = 2
    stack_size = 3
    nb_row = 10
    nb_col = 6

    for batch_size in [None, nb_samples]:
        for border_mode in _convolution_border_modes:
            for subsample in [(1, 1), (2, 2)]:
                if border_mode == 'same' and subsample != (1, 1):
                    continue
                print batch_size, border_mode, subsample
                rows = conv_input_length(nb_row, 3, border_mode, subsample[0])
                cols = conv_input_length(nb_col, 3, border_mode, subsample[1])
                layer_test(convolutional.Deconvolution2D,
                           kwargs={'nb_filter': nb_filter,
                                   'nb_row': 3,
                                   'nb_col': 3,
                                   'output_shape': (batch_size, nb_filter, rows, cols),
                                   'border_mode': border_mode,
                                   'subsample': subsample,
                                   'dim_ordering': 'th'},
                           input_shape=(nb_samples, stack_size, nb_row, nb_col),
                           fixed_batch_size=True)

                layer_test(convolutional.Deconvolution2D,
                           kwargs={'nb_filter': nb_filter,
                                   'nb_row': 3,
                                   'nb_col': 3,
                                   'output_shape': (batch_size, nb_filter, rows, cols),
                                   'border_mode': border_mode,
                                   'dim_ordering': 'th',
                                   'W_regularizer': 'l2',
                                   'b_regularizer': 'l2',
                                   'activity_regularizer': 'activity_l2',
                                   'subsample': subsample},
                           input_shape=(nb_samples, stack_size, nb_row, nb_col),
                           fixed_batch_size=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号