jupyter notebook
shift+table 显示当前光标的函数基本信息
control +? 快速切换评论或者代码
Spyder
control +1 快速切换评论或者代码
配置服务器常用代码
import os gpu_no = '0' # or '1' os.environ["CUDA_VISIBLE_DEVICES"] = gpu_no # os.environ["LD_LIBRARY_PATH"]='/usr/local/cuda-8.0/lib64:'+os.environ["LD_LIBRARY_PATH"] # print(os.environ["LD_LIBRARY_PATH"]) # 定义TensorFlow配置 config=tf.ConfigProto() # 配置GPU内存分配方式,按需增长,很关键 config.gpu_options.allow_growth = True # 配置可使用的显存比例 config.gpu_options.per_process_gpu_memory_fraction = 0.3 with tf.Session(config=config) as sess: sess.run(init) for epoch in range(11): for batch in range(n_batch): batch_xs,batch_ys = mnist.train.next_batch(batch_size) sess.run(train_step,feed_dict={x:batch_xs,y:batch_ys}) acc = sess.run(accuracy,feed_dict={x:mnist.test.images,y:mnist.test.labels}) print("Iter " + str(epoch) + ",Testing Accuracy " + str(acc)) #保存模型 saver.save(sess,'net/my_net.ckpt')