具有ValueError的Keras稀疏输入:稀疏输入不支持从符号张量馈送

时间:2018-12-09 07:28:50

标签: python tensorflow keras

我通过设置sparse=True构建了一个具有稀疏输入的模型,但是在输入稀疏张量时出现了错误。该模型已成功构建但无法运行。 keras现在真的支持稀疏输入吗?

环境:

  • Keras 2.2.4
  • Tensorflow 1.12
  • Python 3.6
  • Windows 10

输入代码:

Input(shape=(self.options.dim_feature[i],), name='input_{}'.format(i), dtype='float', sparse=True)

我提供的数据:

def convert_sparse_matrix_to_sparse_tensor(X):
     coo = X.tocoo()
     indices = np.mat([coo.row, coo.col]).transpose()
     return SparseTensor(indices, coo.data, coo.shape)

完整代码:

完整引用:

    Traceback (most recent call last):
  File "*/src/hypergraph_embedding.py", line 175, in <module>
    h.train(dataset)
  File "*/src/hypergraph_embedding.py", line 88, in train
    epochs=self.options.epochs_to_train, verbose=1)
  File "*\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "*\site-packages\keras\engine\training.py", line 1419, in fit_generator
    initial_epoch=initial_epoch)
  File "*\site-packages\keras\engine\training_generator.py", line 217, in fit_generator
    class_weight=class_weight)
  File "*\site-packages\keras\engine\training.py", line 1218, in train_on_batch
    outputs = self.train_function(ins)
  File "*\site-packages\keras\backend\tensorflow_backend.py", line 2917, in __call__
    'Feeding from symbolic tensors is not '
ValueError: Feeding from symbolic tensors is not supported with sparse inputs.

0 个答案:

没有答案