Я пытался запустить следующий код TensorFlow.Это включало разреженные матрицы, но это, кажется, не работает.Я изменил пример, приведенный в документации к tenorflow ( Link ).Я использую tenorflow версии 1.12.0.
Код:
import tensorflow as tf
import numpy as np
x = tf.sparse.placeholder(shape=[-1,8,8], dtype=np.float32)
x_reshaped = tf.sparse.reshape(x, shape=[-1,64],name='flow_sizes_reshaped')
layer = tf.Variable(initial_value=tf.random_normal(shape=[64, 32],stddev=.05), name='hidden_layer_0', dtype=np.float32)
x_final = tf.sparse.matmul(x_reshaped, layer)
with tf.Session() as sess:
indices = np.array([[0, 2, 0], [0, 5, 1]], dtype=np.int64)
values = np.array([1.0, 2.0], dtype=np.float32)
shape = np.array([1, 8, 8], dtype=np.int64)
print(sess.run(x_final, feed_dict={
x: (indices, values, shape)}))
Ошибка:
2018-12-11 13:24:39.039224: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
File "Test_Sparse.py", line 15, in <module>
x: (indices, values, shape)}))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1132, in _run
raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Tensor Tensor("Const:0", shape=(3,), dtype=int64) may not be fed.
Я не думаю, что это проблема несоответствия размеров, потому что, если я сделаю это изменение в коде:
indices = np.array([[2, 0], [5, 1]], dtype=np.int64)
Я получаю следующую ошибку:
2018-12-11 13:30:01.538664: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
File "Test_Sparse.py", line 15, in <module>
x: (indices, values, shape)}))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 2) for Tensor u'Placeholder_1:0', which has shape '(?, 3)'
Я пытался сделать несколько вещей, но я получаю эту проблему каждый раз.Теперь я думаю о том, чтобы перейти к исходному коду TF и выяснить, почему возникает эта ошибка.