详细搭建过程见https://zhuanlan.zhihu.com/p/26890361,
想要学习更多关于tensorflow搭建CNN的过程只是,可以关注一下知乎上面“城北徐公公”的专栏,网址为:https://zhuanlan.zhihu.com/insight-pixel介绍了很多使用tensorflow的知识,灰常有用!
tensorflow中的嵌入数据过程,我们不仅可以嵌入numpy.ndarray类型的数据,同时也可以嵌入list类型的数据:
1)list类型的数据:
import tensorflow as tf
def graph(X,Y):
x=tf.placeholder(tf.float32,[None,5])
y=tf.placeholder(tf.float32,[None,5])
z=x+y
with tf.Session() as sess:
tf.global_variables_initializer().run()
res=sess.run(z,feed_dict={x:X,y:Y})
print(res)
if __name__=="__main__":
X=[(1,2,3,4,5)]
Y=[(6,7,8,9,10)]
print(type(X))
print(type(Y))
graph(X,Y)
运行结果:
2)numpy.ndarray类型的数据
import tensorflow as tf
def graph(X,Y):
x=tf.placeholder(tf.float32,[None,5])
y=tf.placeholder(tf.float32,[None,5])
z=x+y
with tf.Session() as sess:
tf.global_variables_initializer().run()
res=sess.run(z,feed_dict={x:X,y:Y})
print(res)
if __name__=="__main__":
X=[[1,2,3,4,5]]
Y=[[6,7,8,9,10]]
print(type(X))
print(type(Y))
graph(X,Y)
运行结果: