下面是我正在運行的代碼,我正在執行一篇論文。我需要兩個矩陣,將它們相乘,然後執行聚類。我究竟做錯了什麼?如何在嘗試通過feed_dict傳遞參數時解決Tensorflow Fetch參數錯誤?
import tensorflow as tf
from sklearn.cluster import KMeans
import numpy as np
a = np.random.rand(10,10)
b = np.random.rand(10,5)
F = tf.placeholder("float", [None, 10], name='F')
mask = tf.placeholder("float", [None, 5], name='mask')
def getZfeature(F,mask):
return tf.matmul(F,mask)
def cluster(zfeature):
#km = KMeans(n_clusters=3)
#km.fit(x)
#mu = km.cluster_centers_
return zfeature
def computeQ(zfeature,mu):
print "computing q matrix"
print type(zfeature), type(mu)
#construct model
zfeature = getZfeature(F,mask)
mu = cluster(zfeature)
q = computeQ(zfeature,mu)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
sess.run(q, feed_dict={F: a, mask: b})
的錯誤消息將使人們更容易幫助你聚類的代碼。 – etarion
您可能不知道如果有人幫助過您可以選擇一個答案,我注意到您在過去問過幾個問題,但尚未選擇任何答案。 –