为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的main函数一直报错呢

报错
WARNING:tensorflow:From D:/Python/workspace/Pybasis/Handwritten_digit_main.py:6: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.WARNING:tensorflow:From D:/Python/workspace/Pybasis/Handwritten_digit_main.py:7: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.2019-10-11 13:26:14.887014: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations:  AVX AVX2To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.2019-10-11 13:26:14.889065: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.WARNING:tensorflow:From D:/Python/workspace/Pybasis/Handwritten_digit_main.py:9: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.WARNING:tensorflow:From D:/Python/workspace/Pybasis/Handwritten_digit_main.py:11: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.WARNING:tensorflow:From D:\Python\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.Instructions for updating:Use standard file APIs to check for files with this prefix.Process finished with exit code -1073741819 (0xC0000005)

mian:


import os
import model
import tensorflow as tf
import input_data

data=input_data.read_data_sets('MINST_data',one_hot=True)

with tf.variable_scope("convolutional"):
    x=tf.placeholder(tf.float32,[None,784],name="x")
    keep_prob=tf.placeholder(tf.float32)
    y,variables=model.convolutional(x,keep_prob)

y_=tf.placeholder(tf.float32,[None,10],name='y')
cross_entropy=-tf.reduce_sum(y_*tf.log(y))
train_step=tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction=tf.equal(tf.argmax(y,1),tf.argmax(y_,1))
accuracy=tf.reduce_mean(tf.cast(correct_prediction,tf.float32))

saver=tf.train.Saver(variables)

with tf.Session() as sess:
    merged_summary_op=tf.summary.merge_all()
    summay_writer=tf.summary.FileWriter('/tmp/mnist_log/1',sess.graph)
    summay_writer.add_graph(sess.graph)
    sess.run(tf.global_variables_initializer())

    for i in range(20000):
        batch=data.train.next_batch(50)
        if i%100==0:
            train_accuracy=accuracy.eval(feed_dict={x:batch[0],y_:batch[1],keep_prob:1.0})
            print("step %d, training accuracy %g"%(i,train_accuracy))
        sess.run(train_step,feed_dict={x:batch[0],y_:batch[1],keep_prob:0.5})

    print(sess.run(accuracy,feed_dict={x:data.test.images,y_:data.test.labels,keep_prob:1.0}))

    path=saver.save(
        sess,os.path.join(os.path.dirname(__file__),'data','convolutional.ckpt'),
        write_meta_graph=False,write_state=False)

    print("Saved:",path)


正在回答

1 回答

对应一下版本是不是不一样呀

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我的main函数一直报错呢

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信