0
代碼:Keras InceptionV3 model.predict
from keras.applications import InceptionV3
model = InceptionV3(weights="imagenet")
shape = (None,image_size,image_size,num_channels)
x = tf.placeholder(tf.float32, shape=shape)
adv_x,grad_x = fgm(x, model, model.predict(x), y=y, targeted=True, eps=0, clip_min=-0.5, clip_max=0.5)
adv_,grad_ = batch_eval(sess, [x,y], [adv_x,grad_x], [inputs,targets], args={'batch_size': args['batch_size']})
model.predict(x)
錯誤:
File "/u/.../env/lib/python3.5/site-packages/keras/engine/training.py", line 1594, in predict
batch_size=batch_size, verbose=verbose)
File "/u/.../env/lib/python3.5/site-packages/keras/engine/training.py", line 1208, in _predict_loop
batches = _make_batches(samples, batch_size)
File "/u/.../env/lib/python3.5/site-packages/keras/engine/training.py", line 364, in _make_batches
num_batches = int(np.ceil(size/float(batch_size)))
TypeError: unsupported operand type(s) for /: 'Dimension' and 'float'
我可以在實際圖像使用model.predict,但對tf.placeholders或tf.variables這個錯誤結束 任何人都可以幫助我調試這個錯誤?
我使用Cleverhans圖書館,象徵性的攻擊是建立在tensorflow。編輯上面的問題。我應該能夠做到這一點,因爲我建立了自己的MNIST和CIFAR順序模型,並且此代碼能夠執行。爲什麼預訓練模型會有所不同? –