actnn
actnn copied to clipboard
How to use it for GANs
Thank you for sharing your great work!
Can actNN be used for GAN models? I used actNN with the following GAN architecture, but I got the error. https://github.com/knazeri/edge-connect
Traceback (most recent call last):
File "train.py", line 3, in <module>
main(mode=1)
File "***\edge-connect\main.py", line 50, in main
model = EdgeConnect(config)
File "***\edge-connect\src\edge_connect.py", line 27, in __init__
self.edge_model = EdgeModel(config).to(config.DEVICE)
File "***\edge-connect\src\models.py", line 67, in __init__
generator = actnn.QModule(generator)
File "***\actnn\actnn\actnn\module.py", line 18, in __init__
QModule.convert_layers(model)
File "***\actnn\actnn\actnn\module.py", line 76, in convert_layers
QModule.convert_layers(child)
File "***\actnn\actnn\actnn\module.py", line 48, in convert_layers
child.groups, child.bias, child.dilation, child.padding_mode))
File "***\actnn\actnn\actnn\layers.py", line 137, in __init__
padding, output_padding, groups, bias, dilation, padding_mode)
File "***\Python37\lib\site-packages\torch\nn\modules\conv.py", line 904, in __init__
True, output_padding, groups, bias, padding_mode, **factory_kwargs)
File "***\Python37\lib\site-packages\torch\nn\modules\conv.py", line 602, in __init__
groups, bias, padding_mode, **factory_kwargs)
File "***\Python37\lib\site-packages\torch\nn\modules\conv.py", line 133, in __init__
if bias:
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
I have add the following code to model.py#L61
generator = EdgeGenerator(use_spectral_norm=True)
discriminator = Discriminator(in_channels=2, use_sigmoid=config.GAN_LOSS != 'hinge')
generator = actnn.QModule(generator)
print(generator)
exit()
I would like to seek your advice on this problem. Thanks
This might be a bug in the converter function. @merrymercy could you take a look?
A quicker fix is to disable the bias in conv layers. (set bias=None)