duse4115
天眷LC
采纳率0%
2021-02-27 00:57

请问这个tensorflow的报错怎么修复呢

2021-02-26 16:10:40.320900: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
Traceback (most recent call last):
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call
    return fn(*args)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1263, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1350, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: logits must be 2-dimensional
  [[Node: GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/Softmax = Softmax[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/truediv)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "transform_grade.py", line 46, in <module>
    user_embedding:vector})
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 877, in run
    run_metadata_ptr)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1100, in _run
    feed_dict_tensor, options, run_metadata)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1272, in _do_run
    run_metadata)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1291, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: logits must be 2-dimensional
  [[Node: GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/Softmax = Softmax[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/truediv)]]

Caused by op 'GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/Softmax', defined at:
  File "transform_grade.py", line 8, in <module>
    saver = tf.train.import_meta_graph(model+'.meta')
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1939, in import_meta_graph
    **kwargs)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/meta_graph.py", line 744, in import_scoped_meta_graph
    producer_op_list=producer_op_list)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 442, in import_graph_def
    _ProcessNewOps(graph)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 234, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3289, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3289, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3180, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "/soft/home/python3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1717, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): logits must be 2-dimensional
  [[Node: GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/Softmax = Softmax[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](GeneralModel-d_model100-d_ff512-head4-enc_layer4-1613995208/encoder/encoder_layer1/attention/truediv)]]

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答