2022-02-24 09:24:25 +08:00
|
|
|
# Copyright (c) OpenMMLab. All rights reserved.
|
2020-05-01 00:32:25 +08:00
|
|
|
import torch
|
|
|
|
|
|
|
|
from mmcv.cnn.bricks import Scale
|
|
|
|
|
|
|
|
|
|
|
|
def test_scale():
|
|
|
|
# test default scale
|
|
|
|
scale = Scale()
|
|
|
|
assert scale.scale.data == 1.
|
|
|
|
assert scale.scale.dtype == torch.float
|
|
|
|
x = torch.rand(1, 3, 64, 64)
|
|
|
|
output = scale(x)
|
|
|
|
assert output.shape == (1, 3, 64, 64)
|
|
|
|
|
|
|
|
# test given scale
|
|
|
|
scale = Scale(10.)
|
|
|
|
assert scale.scale.data == 10.
|
|
|
|
assert scale.scale.dtype == torch.float
|
|
|
|
x = torch.rand(1, 3, 64, 64)
|
|
|
|
output = scale(x)
|
|
|
|
assert output.shape == (1, 3, 64, 64)
|