似乎tf.train.replica_device_setter不允许指定使用的gpu.
我想做的是如下:
with tf.device(
tf.train.replica_device_setter(
worker_device='/job:worker:task:%d/gpu:%d' % (deviceindex, gpuindex)):
<build-some-tf-graph>
Run Code Online (Sandbox Code Playgroud) 我已经写了一些代码将数据推送到tensorflow中的队列中,我的队列处理程序的初始化以及所有线程运行的主要功能如下:
def __init__(self):
self.X = tf.placeholder(tf.int64)
self.Y = tf.placeholder(tf.int64)
self.queue = tf.RandomShuffleQueue(dtypes=[tf.int64, tf.int64],
capacity=100,
min_after_dequeue=20)
self.enqueue_op = self.queue.enqueue([self.X, self.Y])
def thread_main(self, sess, coord):
"""Cycle through the dataset until the main process says stop."""
train_fs = open(data_train, 'r')
while not coord.should_stop():
X_, Y_ = get_batch(train_fs)
if not Y: #We're at the end of the file
train_fs = open(data_train, 'r')
X, Y = get_batch(train_fs)
sess.run(self.enqueue_op, feed_dict={self.X:X_, self.Y:Y_})
Run Code Online (Sandbox Code Playgroud)
在培训期间,我正在监视队列的大小。由于某些原因,当我增加向其中推送数据的线程数量时,队列的填充速度会变慢。知道为什么吗?是因为我正在同时读取python文件吗?
编辑:
这是我正在使用的代码,在数据和图形旁边它是完全相同的。该代码在此虚拟数据上的行为符合预期。我有两个观察结果:
首先,生成一个虚拟数据集:
data_train = "./test.txt"
with open(data_train, 'w') as out_stream:
out_stream.write("""[1,2,3,4,5,6]|1\n[1,2,3,4]|2\n[1,2,3,4,5,6]|0\n[1,2,3,4,5,6]|1\n[1,2,5,6]|1\n[1,2,5,6]|0""") …Run Code Online (Sandbox Code Playgroud) 我整天都花在这上面,并且不知道我做错了什么.请帮忙.我使用以下代码创建了包含一些图像的TFRecords文件:
def convert_to_TF(images, labels, name):
label_count = labels.shape[0]
print('There are %d images in this dataset.' % (label_count))
if images.shape[0] != label_count:
raise ValueError('WTF! Devil! There are %d images and %d labels. Go fix yourself!' %
(images.shape[0], label_count))
rows = images.shape[1]
cols = images.shape[2]
depth = images.shape[3]
filename = os.path.join(name + '.tfrecords')
print('Writing', filename)
writer = tf.python_io.TFRecordWriter(filename)
for index in range(label_count):
image_raw = images[index].tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(int(labels[index])),
'image_raw': _bytes_feature(image_raw)}))
writer.write(example.SerializeToString())
Run Code Online (Sandbox Code Playgroud)
然后我尝试用以下内容读取保存的TFRecords文件:
def read_and_decode(filename_queue): …Run Code Online (Sandbox Code Playgroud) 例如,我的张量形状是[128,128,3]并且它的范围是随机的,那么我想将这个张量中的所有num缩放到[0,255],我应该使用tensorflow中的哪个函数来做它?谢谢
这个问题是关于TFDetect演示,它是Tensorflow Android Camera Demo的一部分.描述说,
演示基于可扩展对象检测的模型,使用深度神经网络实时定位和跟踪摄像机预览中的人员.
当我运行演示时,应用程序在检测到的对象周围创建了一个框,并为每个对象分配了一个小数(我猜是置信度得分).我的问题是,如何在这里执行跟踪.它是多个对象跟踪(在此描述),其中有一个id分配给每个轨道并且轨道存储在内存中,或者只是检测多个帧中的对象以查看对象是如何移动的?
如果我错过任何事情,请纠正我.
我的代码很简单:
import tensorflow as tf
import numpy as np
from tensorflow.python import debug as tf_debug
with tf.name_scope("multiplication"):
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = tf.div(a, b, name="mult")
with tf.Session() as session:
session = tf_debug.LocalCLIDebugWrapperSession(session)
session.add_tensor_filter("has_inf_or_nan", tf_debug.has_inf_or_nan)
session.run([ c],feed_dict={a:100, b:10})
Run Code Online (Sandbox Code Playgroud)
但当我跑它时:
>python test.py --debug
...
ImportError: No module named '_curses'
...
ImportError: No module named 'readline'`
Run Code Online (Sandbox Code Playgroud)
我在网上查了一下,发现Windows 10不支持"_curses".这是否意味着我不能在Windows 10上使用Tensorflow Debugger?
我正在使用传统的序列到序列框架在TensorFlow 1.0.1中构建编码器 - 解码器模型.当我在编码器和解码器中有一层LSTM时,一切正常.但是,当我尝试使用包裹在a中的> 1层LSTM时MultiRNNCell,我在调用时出错tf.contrib.legacy_seq2seq.rnn_decoder.
完整的错误是在这篇文章的最后,但简而言之,它是由一条线引起的
(c_prev, m_prev) = state
Run Code Online (Sandbox Code Playgroud)
在投掷的TensorFlow中TypeError: 'Tensor' object is not iterable..我对此感到困惑,因为我传递的初始状态rnn_decoder确实是一个应该是的元组.据我所知,使用1层或> 1层的唯一区别是后者涉及使用MultiRNNCell.使用它时是否有一些我应该知道的API怪癖?
这是我的代码(基于此 GitHub仓库中的示例).道歉的长度; 这是我能做到的最小化,同时仍然是完整和可验证的.
import tensorflow as tf
import tensorflow.contrib.legacy_seq2seq as seq2seq
import tensorflow.contrib.rnn as rnn
seq_len = 50
input_dim = 300
output_dim = 12
num_layers = 2
hidden_units = 100
sess = tf.Session()
encoder_inputs = []
decoder_inputs = []
for i in range(seq_len):
encoder_inputs.append(tf.placeholder(tf.float32, shape=(None, input_dim),
name="encoder_{0}".format(i)))
for i in range(seq_len + …Run Code Online (Sandbox Code Playgroud) 当我用Spyder导入TensorFlow时:
import tensorflow as tf
Run Code Online (Sandbox Code Playgroud)
然后我面临以下错误:
ModuleNotFoundError:没有名为'tensorflow'的模块
我怎样才能克服这个问题?
我想在我的Windows 7 64位计算机上安装Tensorslow.
我用Python 3.5安装了Anaconda.
之后我做了
conda install theano
它成功完成了.
conda install mingw libpython
成功完成了.
pip install tensorflow
错误
我无法以与安装这些其他软件包相同的方式安装Tensorflow.我错过了什么基本的东西?
tensorflow ×10
python ×3
anaconda ×1
android ×1
conda ×1
distributed ×1
jupyter ×1
python-3.x ×1
spyder ×1
windows ×1