我正在尝试评估我的深度学习 RNN 模型,但我一直收到这个错误。我完全不知道错误意味着什么,我无法解决它。任何帮助表示赞赏。谢谢。
这是我用来评估模型的代码:
model = keras.models.load_model('D:/Semester 3.2 OFFICIAL/Deep Learning/Assignment 2/test_model_14 files/Model14Checkpoint-188-0.60.h5')
model.load_weights('D:/Semester 3.2 OFFICIAL/Deep Learning/Assignment 2/test_model_14 files/Model14Checkpoint-188-0.60.h5')
evaluate = model.evaluate(X_test_seq_padded, y_test, batch_size=128)
loss = evaluate[0]
acc = evaluate[1] * 100
print("Loss: {:0.3f} - Accuracy: {:0.3f}%".format(loss,acc))
这是它返回的错误:
128/8510 [..............................] - ETA: 1:05
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-8-8b3cba2991da> in <module>
13 model = keras.models.load_model('D:/Semester 3.2 OFFICIAL/Deep Learning/Assignment 2/test_model_14 files/Model14Checkpoint-188-0.60.h5')
14 model.load_weights('D:/Semester 3.2 OFFICIAL/Deep Learning/Assignment 2/test_model_14 files/Model14Checkpoint-188-0.60.h5')
---> 15 evaluate = model.evaluate(X_test_seq_padded, y_test, batch_size=128)
16
17 loss = evaluate[0]
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\keras\engine\training.py in evaluate(self, x, y, batch_size, verbose, sample_weight, steps, callbacks, max_queue_size, workers, use_multiprocessing)
928 max_queue_size=max_queue_size,
929 workers=workers,
--> 930 use_multiprocessing=use_multiprocessing)
931
932 def predict(self,
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in evaluate(self, model, x, y, batch_size, verbose, sample_weight, steps, callbacks, max_queue_size, workers, use_multiprocessing, **kwargs)
488 sample_weight=sample_weight, steps=steps, callbacks=callbacks,
489 max_queue_size=max_queue_size, workers=workers,
--> 490 use_multiprocessing=use_multiprocessing, **kwargs)
491
492 def predict(self, model, x, batch_size=None, verbose=0, steps=None,
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _model_iteration(self, model, mode, x, y, batch_size, verbose, sample_weight, steps, callbacks, max_queue_size, workers, use_multiprocessing, **kwargs)
473 mode=mode,
474 training_context=training_context,
--> 475 total_epochs=1)
476 cbks.make_logs(model, epoch_logs, result, mode)
477
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in run_one_epoch(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs)
126 step=step, mode=mode, size=current_batch_size) as batch_logs:
127 try:
--> 128 batch_outs = execution_function(iterator)
129 except (StopIteration, errors.OutOfRangeError):
130 # TODO(kaftan): File bug about tf function and errors.OutOfRangeError?
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py in execution_function(input_fn)
96 # `numpy` translates Tensors to values in Eager mode.
97 return nest.map_structure(_non_none_constant_value,
---> 98 distributed_function(input_fn))
99
100 return execution_function
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\def_function.py in __call__(self, *args, **kwds)
566 xla_context.Exit()
567 else:
--> 568 result = self._call(*args, **kwds)
569
570 if tracing_count == self._get_tracing_count():
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\def_function.py in _call(self, *args, **kwds)
636 *args, **kwds)
637 # If we did not create any variables the trace we have is good enough.
--> 638 return self._concrete_stateful_fn._filtered_call(canon_args, canon_kwds) # pylint: disable=protected-access
639
640 def fn_with_cond(*inner_args, **inner_kwds):
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\function.py in _filtered_call(self, args, kwargs)
1609 if isinstance(t, (ops.Tensor,
1610 resource_variable_ops.BaseResourceVariable))),
-> 1611 self.captured_inputs)
1612
1613 def _call_flat(self, args, captured_inputs, cancellation_manager=None):
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\function.py in _call_flat(self, args, captured_inputs, cancellation_manager)
1690 # No tape is watching; skip to running the function.
1691 return self._build_call_outputs(self._inference_function.call(
-> 1692 ctx, args, cancellation_manager=cancellation_manager))
1693 forward_backward = self._select_forward_and_backward_functions(
1694 args,
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\function.py in call(self, ctx, args, cancellation_manager)
543 inputs=args,
544 attrs=("executor_type", executor_type, "config_proto", config),
--> 545 ctx=ctx)
546 else:
547 outputs = execute.execute_with_cancellation(
~\anaconda3\envs\three point seven\lib\site-packages\tensorflow_core\python\eager\execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
65 else:
66 message = e.message
---> 67 six.raise_from(core._status_to_exception(e.code, message), None)
68 except TypeError as e:
69 keras_symbolic_tensors = [
~\anaconda3\envs\three point seven\lib\site-packages\six.py in raise_from(value, from_value)
InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: indices[28,27] = 10792 is not in [0, 10000)
[[node sequential_3/embedding_3/embedding_lookup (defined at <ipython-input-8-8b3cba2991da>:15) ]]
[[sequential_3/embedding_3/embedding_lookup/_17]]
(1) Invalid argument: indices[28,27] = 10792 is not in [0, 10000)
[[node sequential_3/embedding_3/embedding_lookup (defined at <ipython-input-8-8b3cba2991da>:15) ]]
0 successful operations.
0 derived errors ignored. [Op:__inference_distributed_function_8770]
Errors may have originated from an input operation.
Input Source operations connected to node sequential_3/embedding_3/embedding_lookup:
sequential_3/embedding_3/embedding_lookup/7696 (defined at C:\Users\acer\anaconda3\envs\three point seven\lib\contextlib.py:112)
Input Source operations connected to node sequential_3/embedding_3/embedding_lookup:
sequential_3/embedding_3/embedding_lookup/7696 (defined at C:\Users\acer\anaconda3\envs\three point seven\lib\contextlib.py:112)
Function call stack:
distributed_function -> distributed_function