示例#1
0
# create batching lambda function
train_batches = bot.partial(bot.Batches,
                            dataset=train_set,
                            shuffle=True,
                            drop_last=True,
                            max_options=200)
valid_batches = bot.partial(bot.Batches,
                            dataset=valid_set,
                            shuffle=False,
                            drop_last=False)

print('=====> Input whitening')

# create input whitening network
Λ, V = bot.eigens(bot.patches(train_set['data'][:10000, :, 4:-4, 4:-4]))
input_whitening_net = bot.network(conv_pool_block=bot.conv_pool_block_pre,
                                  prep_block=bot.partial(bot.whitening_block,
                                                         Λ=Λ,
                                                         V=V),
                                  scale=1 / 16,
                                  types={
                                      nn.ReLU:
                                      bot.partial(nn.CELU, 0.3),
                                      bot.BatchNorm:
                                      bot.partial(bot.GhostBatchNorm,
                                                  num_splits=16,
                                                  weight=False)
                                  })

print('=====> Building model (with input whitening network)')
示例#2
0
valid_set = bot.preprocess(
    dataset_dict['valid'],
    [bot.transpose, normalize, bot.to(torch.float16)])  #

print('=====> Data preprocessed (on GPU)')

# create batching lambda function
valid_batches = bot.partial(bot.Batches,
                            dataset=valid_set,
                            shuffle=False,
                            drop_last=False)

print('=====> Input whitening')

# create input whitening network
Λ, V = bot.eigens(bot.patches(valid_set['data'][:10000, :, 4:-4, 4:-4]))
input_whitening_net = bot.network(conv_pool_block=bot.conv_pool_block_pre,
                                  prep_block=bot.partial(bot.whitening_block,
                                                         Λ=Λ,
                                                         V=V),
                                  scale=1 / 16,
                                  types={
                                      nn.ReLU:
                                      bot.partial(nn.CELU, 0.3),
                                      bot.BatchNorm:
                                      bot.partial(bot.GhostBatchNorm,
                                                  num_splits=16,
                                                  weight=False)
                                  })

print('=====> Building model (with input whitening network)')