我正在使用Pycharm进行Python编码,我想在整个代码中更改特定变量的名称.这个操作有键盘快捷键吗?
在Matlab中我可以使用ctrl + shift.
例如:
old_name=5
x=old_name*123
Run Code Online (Sandbox Code Playgroud)
会变成:
new_name=5
x=new_name*123
Run Code Online (Sandbox Code Playgroud)
无需更改两个old_name引用.
谢谢!
我正在使用TensorFlow v0.12训练分类CNN,然后想要使用训练模型为新数据创建标签.
在训练脚本结束时,我添加了以下代码行:
saver = tf.train.Saver()
save_path = saver.save(sess,'/home/path/to/model/model.ckpt')
Run Code Online (Sandbox Code Playgroud)
培训完成后,文件夹中出现的文件为:1.checkpoint ; 2. model.ckpt.data-00000-of-00001 ; 3. model.ckpt.index ; 4. model.ckpt.meta
然后我尝试使用.meta文件恢复模型.在本教程之后,我将以下行添加到我的分类代码中:
saver=tf.train.import_meta_graph(savepath+'model.ckpt.meta') #line1
Run Code Online (Sandbox Code Playgroud)
然后:
saver.restore(sess, save_path=savepath+'model.ckpt') #line2
Run Code Online (Sandbox Code Playgroud)
在更改之前,我需要再次构建图形,然后写入(而不是line1):
saver = tf.train.Saver()
Run Code Online (Sandbox Code Playgroud)
但是,删除图形构建,并使用line1以便还原它,引发了错误.错误是我在我的代码中使用了图中的变量,并且python没有识别它:
predictions = sess.run(y_conv, feed_dict={x: patches,keep_prob: 1.0})
Run Code Online (Sandbox Code Playgroud)
python无法识别y_conv参数.有一种方法可以使用元图恢复变量吗?如果不是,如果我不能使用原始图形中的变量,那么这个恢复有什么帮助?
我知道这个问题不是那么清楚,但我很难用文字表达问题.对不起...
谢谢你的回答,感谢你的帮助!投资回报率.
我训练了一个模型(根据MNIST教程)并保存了它:
saver = tf.train.Saver()
save_path = saver.save(sess,'/path/to/model.ckpt')
Run Code Online (Sandbox Code Playgroud)
我想使用保存的模型来查找新批次图像的标签.我加载模型并用数据库测试它:
# load MNIST data
folds = build_database_tuple.load_data(data_home_dir='/path/to/database')
# starting the session. using the InteractiveSession we avoid build the entiee comp. graph before starting the session
sess = tf.InteractiveSession()
# start building the computational graph
...
BUILD AND DEFINE ALL THE LAYERS
...
y_conv=tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)
# TRAIN AND EVALUATION:
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y_conv), reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.initialize_all_variables())
saver = …Run Code Online (Sandbox Code Playgroud) python machine-learning neural-network python-2.7 tensorflow
我正在TensorFlow中开始一个交互式会话,在定义了所有我开始训练的变量后,评估网络.
这两个命令有什么区别:
tf.global_variables_initializer().run()sess.run(tf.initialize_all_variables())直到今天我使用了第二个命令,但最近我注意到了第一个命令.
谢谢 :)
2 年前,我在 TensorFlow 中编写代码,作为数据加载的一部分,我使用了函数“load_csv_without_header”。现在,当我运行代码时,我收到消息:
WARNING:tensorflow:From C:\Users\Roi\Desktop\Code_Win_Ver\code_files\Tensor_Flow\version1\build_database_tuple.py:124: load_csv_without_header (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.data instead.
Run Code Online (Sandbox Code Playgroud)
如何使用 'tf.data' 而不是当前函数?如果没有带有 tf.data 的 csv 标头,我如何才能以相同的格式使用相同的 dtype?我在 Python 3.5 上使用 TF 版本 1.8.0。
感谢你的帮助!