ccc2876 / MalGAN

My replication of the paper "Generating Adversarial Malware Examples for Black-Box Attacks Based on GAN"
15 stars 4 forks source link

bugs #2

Open cuge1995 opened 3 years ago

cuge1995 commented 3 years ago
0.9872029250457038 0.9854014598540146
Traceback (most recent call last):
  File "code/MalGAN.py", line 417, in <module>
    main()
  File "code/MalGAN.py", line 375, in main
    train(200, blackbox, generator, d_optimizer, g_optimizer, TRAIN_TPR, TEST_TPR, sigmoid, isFirst=True)
  File "code/MalGAN.py", line 247, in train
    fake_mal_data, ymal_batch)
  File "code/MalGAN.py", line 139, in train_discriminator
    prediction_real = discriminator(real_data)
  File "/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "code/MalGAN.py", line 60, in forward
    x = self.out(x)
  File "/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/lib/python3.7/site-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "//python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 87, in forward
    return F.linear(input, self.weight, self.bias)
  File "/lib/python3.7/site-packages/torch/nn/functional.py", line 1370, in linear
    ret = torch.addmm(bias, input, weight.t())
RuntimeError: size mismatch, m1: [64 x 512], m2: [256 x 1] at /pytorch/aten/src/TH/generic/THTensorMath.cpp:197
cuge1995 commented 3 years ago

solved by replace torch.nn.Linear(256, n_out) in line 38 with torch.nn.Linear(512, n_out)