File "/home/server-train/data/nezha_recognizer.py", line 50, in predict_nezha
scores = model(x)
File "/root/anaconda3/envs/nlp/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1013, in __call__
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
File "/root/anaconda3/envs/nlp/lib/python3.6/site-packages/tensorflow/python/keras/engine/input_spec.py", line 197, in assert_input_compatibility
raise TypeError('Inputs to a layer should be tensors. Got: %s' % (x,))
TypeError: Inputs to a layer should be tensors. Got: 财经,金融,快讯,财经网,科技,汽车,资本,互联网,腾讯,杂志
Exception ignored in: <bound method _CheckpointRestoreCoordinatorDeleter.__del__ of <tensorflow.python.training.tracking.util._CheckpointRestoreCoordinatorDeleter object at 0x7f3a42786a20>>
Traceback (most recent call last):
File "/root/anaconda3/envs/nlp/lib/python3.6/site-packages/tensorflow/python/training/tracking/util.py", line 162, in __del__
File "/root/anaconda3/envs/nlp/lib/python3.6/site-packages/tensorflow/python/training/tracking/util.py", line 107, in node_names
TypeError: 'NoneType' object is not callable
原因:
调用模型应该用scores = model.predict(x)而不是用上面的model(x),这两个方法使用的类型不同,前者要求的是list(或ndarray 未再确认)后者要求是Tensor出现了上面的问题。