AttributeError EfficientNet object has no attribute act1 same error every time any one know how to solve it ?? #307
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.activation.PReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Sigmoid' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
L:\spn\Anaconda3\lib\site-packages\torch\serialization.py:786: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set
torch.nn.Module.dump_patches = Trueand use the patch tool to revert the changes.warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "C:\Users\spn\Fake\SimSwap\train.py", line 139, in
model.initialize(opt)
File "C:\Users\spn\Fake\SimSwap\models\projected_model.py", line 57, in initialize
self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{})
File "C:\Users\spn\Fake\SimSwap\pg_modules\projected_discriminator.py", line 161, in init
self.feature_network = F_RandomProj(**backbone_kwargs)
File "C:\Users\spn\Fake\SimSwap\pg_modules\projector.py", line 108, in init
self.pretrained, self.scratch = _make_projector(im_res=im_res, cout=self.cout, proj_type=self.proj_type, expand=self.expand)
File "C:\Users\spn\Fake\SimSwap\pg_modules\projector.py", line 64, in _make_projector
pretrained = _make_efficientnet(model)
File "C:\Users\spn\Fake\SimSwap\pg_modules\projector.py", line 35, in _make_efficientnet
pretrained.layer0 = nn.Sequential(model.conv_stem, model.bn1, model.act1, *model.blocks[0:2])
File "L:\spn\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1207, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'EfficientNet' object has no attribute 'act1'
same issue
I removed
model.act1
from
pretrained.layer0 = nn.Sequential(model.conv_stem, model.bn1, model.act1, *model.blocks[0:2])
the train starts fine. No idea what impact it would have on the results though. Also this might throw an error if you are trying to load pretrained weights
I replaced the
model.act1bynn.SiLU(inplace=False)after checking the meaning of act1. It works fine while training, and the validation result seems to be fine. However, I think I met the problem you mentioned : when I was trying to load my trained 512 simswap to do some infer, I was told that :Pretrained network G has fewer layers; The following are not initialized: ['down0', 'first_layer', 'last_layer', 'up0']
So now I am trying to infer with the training code provided by @neuralchen
if yo had another problem that tell you
num_samples should be a positive integer value, but got num_samples=0
...................
thin just change the train start code by add the batchsize value --batchSize 4
.............
!python train.py --name simswap224_test --batchSize 4 --gpu_ids 0 --dataset ./content/TrainingData/vggface2_crop_arcfacealign_224 --Gdeep FalsIs it possible to solve this problem without modifying the training script?
@zwang970201
You can't :(
I search for this problem for 1 week and this was the best Solution
I observed that error with two few classes, that is the number of subjects in training data were too small. I think for each +4 in batch size you need 2 more identities,
batch size 4 = 2 identities
batch size 8 = 4 identities and so on...
Can you tell me the code in which file should be changed?