kuza55 / keras-extras

Extra batteries for Keras

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid argument error

Nishath-arfa opened this issue · comments

this is the below code which has got errors
x_test_pred = np.argmax(classifier.predict(x_test[:47]), axis=1)
nb_correct_pred = np.sum(x_test_pred == np.argmax(y_test[:47], axis=1))

print("Original test data (first 100 images):")
print("Correctly classified: {}".format(nb_correct_pred))
print("Incorrectly classified: {}".format(47-nb_correct_pred))

and the error is
InvalidArgumentError Traceback (most recent call last)
in
1 #print(x_test)
----> 2 x_test_pred = np.argmax(classifier.predict(x_test[:47]), axis=1)
3 nb_correct_pred = np.sum(x_test_pred == np.argmax(y_test[:47], axis=1))
4
5 print("Original test data (first 100 images):")

~/Documents/adversarial-robustness-toolbox-master/art/classifiers/keras.py in predict(self, x, logits, batch_size)
220 for b in range(int(np.ceil(x_.shape[0] / float(batch_size)))):
221 begin, end = b * batch_size, min((b + 1) * batch_size, x_.shape[0])
--> 222 preds[begin:end] = self.preds([x[begin:end]])[10]
223
224 if not logits and not self._custom_activation:

~/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in call(self, inputs)
2713 return self._legacy_call(inputs)
2714
-> 2715 return self._call(inputs)
2716 else:
2717 if py_any(is_tensor(x) for x in inputs):

~/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in _call(self, inputs)
2673 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
2674 else:
-> 2675 fetched = self._callable_fn(*array_vals)
2676 return fetched[:len(self.outputs)]
2677

~/Downloads/ENTER/envs/gans/lib/python3.6/site-packages/tensorflow/python/client/session.py in call(self, *args)
1452 else:
1453 return tf_session.TF_DeprecatedSessionRunCallable(
-> 1454 self._session._session, self._handle, args, status, None)
1455
1456 def del(self):

~/Downloads/ENTER/envs/gans/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in exit(self, type_arg, value_arg, traceback_arg)
517 None, None,
518 compat.as_text(c_api.TF_Message(self.status.status)),
--> 519 c_api.TF_GetCode(self.status.status))
520 # Delete the underlying status object from memory otherwise it stays alive
521 # as there is a reference to status from this from the traceback due to

InvalidArgumentError: Matrix size-incompatible: In[0]: [47,2048], In[1]: [100352,1024]
[[Node: dense_1_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](flatten_1_1/Reshape, dense_1_1/kernel/read)]]