gongzhitaao / tensorflow-adversarial

Crafting adversarial images
MIT License
223 stars 70 forks source link

ex_00.py for different model #5

Closed Poomathi closed 6 years ago

Poomathi commented 6 years ago

Hi,

I tried to change the model to one similar to(https://github.com/radioML/examples/blob/master/modulation_recognition/RML2016.10a_VTCNN2_example.ipynb) this model. Where total params is 2,830,427 (way more than your simple model). While generating adversarial crafting graph, I receive the following error Traceback (most recent call last): File "RML_TOS.py", line 121, in x_adv = fgsm(_model_fn, x, epochs=9, eps=0.0001) File "/home/pduraisamy/Adversarial/adversarial/fgsm.py", line 23, in fgsm ybar = model(x_adv) File "RML_TOS.py", line 117, in _modelfn logits, = ybar.op.inputs ValueError: too many values to unpack Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function remove at 0x7fb07c21f140> ignored

Does it mean it couldn't handle deep network? Appreciate your help.

gongzhitaao commented 6 years ago

Did you use Theano backend or Tensorflow backend? The ValueError: too many values to unpack seems to indicate that you are using Theano as backend.

Poomathi commented 6 years ago

I am using tensorflow as backend. Using TensorFlow backend.

Poomathi commented 6 years ago

Below is my model structure if it helps model = Sequential([ ZeroPadding2D(padding=(0,2),input_shape=input_shape), Conv2D(filters=256, kernel_size=(1, 3), padding='valid',activation="relu", name="conv1", kernel_initializer='glorot_uniform'), Dropout(0.5), ZeroPadding2D(padding=(0,2)), Conv2D(filters=80, kernel_size=(2, 3), padding='valid',activation="relu", name="conv2", kernel_initializer='glorot_uniform'), Dropout(0.5), Flatten(), Dense(256, activation="relu", name="dense1", kernel_initializer='he_normal' ), Dropout(0.5), Dense(11, name="dense2", kernel_initializer='henormal'), Activation('softmax'), Reshape([11])]) since I am new to tensorflow, I am struggling to figure out why it produces ValueError at line logits, = ybar.op.inputs. Any help is appreciated.Thanks.

Poomathi commented 6 years ago

After removing last layer Reshape([11]). it works perfectly fine. Not sure why it didn't like the Reshape layer.

gongzhitaao commented 6 years ago

It makes sense. The ybar.op.inputs is the input for softmax operation, i.e., logits, input for Reshape operation may be different, you could print ybar.op to see what's available. It is Keras internal implementation, this ybar.op.inputs is more of a hack, and might be changed in later Keras version.