资源简介

用tensorflow框架,深度学习中卷积神经网络cnn模型,对电影评论进行情感二分类。

资源截图

代码片段和文件信息

import numpy as np
import tensorflow as tf


#Input: x
x_image = tf.placeholder(tf.float32shape=[55])
x = tf.reshape(x_image[1551])

#Filter: W
W_cpu = np.array([[111][0-10][0-11]]dtype=np.float32)
W = tf.Variable(W_cpu)
W = tf.reshape(W [3311])

#Stride & Padding
strides=[1 1 1 1]
padding=‘VALID‘

#Convolution
y = tf.nn.conv2d(x W strides padding)




x_data = np.array([[10000][21121][11220][22100][21211]]dtype=np.float32)
with tf.Session() as sess:
    init = tf.initialize_all_variables()
    sess.run(init)

    x = (sess.run(x feed_dict={x_image: x_data}))
    W = (sess.run(W feed_dict={x_image: x_data}))
    y = (sess.run(y feed_dict={x_image: x_data}))

    print “The shape of x:\t“ x.shape “\t and the x.reshape(55) is :“
    print x.reshape(55)
    print ““

    print “The shape of x:\t“ W.shape “\t and the W.reshape(33) is :“
    print W.reshape(33)
    print ““

    print “The shape of y:\t“ y.shape “\t and the y.reshape(33) is :“
    print y.reshape(33)
    print ““



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件      501046  2016-07-03 21:57  code_cnn_recursive\cnn_sentiment.tar.gz
     文件    11602452  2016-07-03 22:01  code_cnn_recursive\mnist.tar.gz
     文件        7662  2016-07-03 22:15  code_cnn_recursive\recursive.tar.gz
     文件        1105  2016-07-03 22:17  code_cnn_recursive\toy-example-cnn_2d.py
     文件         771  2016-07-03 22:32  code_cnn_recursive\toy-example-max_pool.py
     目录           0  2016-07-03 22:36  code_cnn_recursive\

评论

共有 条评论