Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行example时报错 #49

Open
ZhouTaiji opened this issue Jan 30, 2021 · 1 comment
Open

运行example时报错 #49

ZhouTaiji opened this issue Jan 30, 2021 · 1 comment

Comments

@ZhouTaiji
Copy link

ZhouTaiji commented Jan 30, 2021

你好,我在运行example文件夹中的demo时,对同样的数据,使用model.fit训练与model.evaluate评估均无异常,但使用model.predict进行预测将会报如下的错:

`Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1172, in concat_v2
tld.op_callbacks, values, axis)
tensorflow.python.eager.core._FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/workspace/src/demo_tn.py", line 298, in
train(Strategy)
File "/workspace/src/demo_tn.py", line 255, in train
score = model.predict(features)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 88, in _method_wrapper
return method(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 1285, in predict
all_outputs = nest.map_structure_up_to(batch_outputs, concat, outputs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 1118, in map_structure_up_to
**kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 1214, in map_structure_with_tuple_paths_up_to
*flat_value_lists)]
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 1213, in
results = [func(*args, **kwargs) for args in zip(flat_path_list,
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 1116, in
lambda _, *values: func(*values), # Discards the path arg.
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 1740, in concat
return array_ops.concat(tensors, axis=axis)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py", line 1606, in concat
return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1177, in concat_v2
values, axis, name=name, ctx=_ctx)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1209, in concat_v2_eager_fallback
_attr_T, values = _execute.args_to_matching_eager(list(values), ctx)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 263, in args_to_matching_eager
t, dtype, preferred_dtype=default_dtype, ctx=ctx))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1341, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 321, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 262, in constant
allow_broadcast=True)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 270, in _constant_impl
t = convert_to_eager_tensor(value, ctx, dtype)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 96, in convert_to_eager_tensor
return ops.EagerTensor(value, ctx.device_name, dtype)
ValueError: Attempt to convert a value (None) with an unsupported type (<class 'NoneType'>) to a Tensor.`

我在docker中运行的程序,tf版本为2.2/2.3时均会出现此错误,将模型改为tf版本,其他不变也不会报错,我对example中代码未作出修改,只修改了config中的预测日期:

PREDICT_DT = '2020-05-12'

然后对main.py 81行处的代码进行修改,增加batch_size参数

dataset = read_dataset(C.DATA_DIR, [C.PREDICT_DT], C.FILE_MATCH_PATTERN, C.BATCH_SIZE, parse_line_batch)

请问这里报错是哪里有问题呢?

@zhangqianjin
Copy link

tensornet中 model/Model.py中 x, y, sample_weight = data_adapter.unpack_x_y_sample_weight(data) ,return部分代码需要修改,没有值不返回

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants