假设我想用KMeans方法找到质心。在
对于第一次迭代,我想使用initFirstCentroids从数据集X中获取一些示例数据
在第二次迭代之前,用户可以看到第一次迭代的结果,并输入第二次迭代的初始质心。在
在静态图中,输入定义为tf.持牌人(tf.float32型,形状=(无,D))。由于点数未知,我无法将其作为tf.变量在
当我需要打电话给sess.运行()为了计算,它总是要求我提供feed-dict,但实际上我的数据集没有改变。我可以只输入一次吗tf.变量)在
# k=3, centroids is a tf.Variable
dataset=np.array([[1.,2.],[3.,4.],[5.,6.],[7.,8.],[2.5,5.2],[6.6,4.4]])
With tf.Session() as sess:
# the feed_dict is the same for the entire session. can I just input once?
sess.run(init)
sess.run(initFirstCentroids, feed_dict={X:dataset})
for i in range(10):
centroids_value=sess.run(iter_centroids,feed_dict={X:dataset})
print(centroids_value)
userInput=input() # say I can input [ [2.,5.],[3.,3.],[6.5,6.] ]
userArray=np.array(userInput,np.float)
assign_userInput=tf.assign(centroids,userArray)
sess.run(assign_userInput,feed_dict={X:dataset})
目前没有回答
相关问题 更多 >
编程相关推荐