一、tensorflow的 jupyter环境 error :UnrecognizedFlagError: Unknown command line flag ‘f’ 解决办法:
tf.app.flags.DEFINE_string(‘f’, ‘’, ‘kernel’)
二、DuplicateFlagError: The flag ‘xxx’ is defined twice.的错误处理
import tensorflow as tf
tf.reset_default_graph()
try:
flag =tf.get_variable(name='flag',shape=[2],initializer=tf.constant_initializer(1.0))
FLAGS = tf.flags.FLAGS
tf.flags.DEFINE_string('f', '', 'kernel')
tf.flags.DEFINE_string('ckpt_path', 'model/model.ckpt-100000', '''模型保存路径''')
tf.flags.DEFINE_float('learning_rate', 0.0001, '''初始学习率''')
tf.flags.DEFINE_integer('train_steps', 50000, '''总的训练轮数''')
tf.flags.DEFINE_boolean('is_use_gpu', False, '''是否使用GPU''')
except:
print("has been defined")
print('模型保存路径: {}'.format(FLAGS.ckpt_path))
print('初始学习率: {}'.format(FLAGS.learning_rate))
print('总的训练次数: {}'.format(FLAGS.train_steps))
print('是否使用GPU: {}'.format(FLAGS.is_use_gpu))
pip国内的一些镜像
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
修改源方法:
临时使用:
可以在使用pip的时候在后面加上-i参数,指定pip源
eg: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
永久修改:
linux:
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows:
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,在pip 目录下新建文件pip.ini,内容如下
或者按照网友的建议:win+R 打开用户目录%HOMEPATH%,在此目录下创建 pip 文件夹,在 pip 目录下创建 pip.ini 文件, 内容如下