Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I use predict_2.py with a BP neural network model, why can not get a accuracy like train accuracy? #9

Open
Wchenghui opened this issue May 3, 2017 · 0 comments

Comments

@Wchenghui
Copy link

Wchenghui commented May 3, 2017

this is code:
def predictint(imvalue):

     with tf.Graph().as_default():
      def addlayer(input_data,insize,outsize,act_function=None):
            W=tf.Variable(tf.random_normal([insize,outsize]))
            b=tf.Variable(tf.zeros([outsize]))+0.1
            out_data=tf.matmul(input_data,W)+b
            if act_function==None:
	         return out_data
            elif act_function=="relu":
	         return tf.nn.relu(out_data)
            elif act_function=="softmax":
	          return tf.nn.softmax(out_data)
           else:
	          return tf.nn.sigmoid(out_data)
           x_input=tf.placeholder(tf.float32,[None,784])
          #y_input=tf.placeholder(tf.float32,[None,10])
           l1=addlayer(x_input,784,64,act_function="relu")
           l2=addlayer(l1,64,10,act_function="softmax")	    
          init_op = tf.initialize_all_variables()
          saver = tf.train.Saver()	    
    
              with tf.Session() as sess:
	         sess.run(init_op)
	         saver.restore(sess, "./model.ckpt")
                 prediction=tf.argmax(l2,1)
	         return prediction.eval(feed_dict={x_input: [imvalue]}, session=sess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant