什么是"相同"和"有效"填充之间的区别tf.nn.max_pool的tensorflow?
在我看来,'VALID'意味着当我们做最大池时,边缘外没有零填充.
根据深度学习的卷积算法指南,它表示池操作符中没有填充,即只使用'VALID' tensorflow.但是什么是最大池的"相同"填充tensorflow?
在张量流函数tf.nn.conv2d中,填充选项只有'SAME'和'VALID'.
但是在Caffe的conv层中,有pad选项可以定义要(隐式)添加到输入的每一侧的像素数.
如何在Tensorflow中实现这一目标?
非常感谢你.
我在我的PC上运行cifar10网络,在完成培训并运行eval脚本后,出现以下错误:
2016-06-01 14:37:14.238317: precision @ 1 = 0.000
Traceback (most recent call last):
File "<ipython-input-1-adf2ca85bb77>", line 1, in <module>
runfile('/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test/cifar10_eval_test.py', wdir='/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test')
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 85, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test/cifar10_eval_test.py", line 107, in <module>
tf.app.run()
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
sys.exit(main(sys.argv))
File "/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test/cifar10_eval_test.py", line 104, in main
evaluate()
File "/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test/cifar10_eval_test.py", line 94, in evaluate
eval_once(saver, summary_writer, top_k_op, summary_op)
File "/home/kang/Documents/work_code_PC1/py_tensorflow_learning/cifar10CNN_test/cifar10_eval_test.py", line 72, in eval_once
coord.join(threads, stop_grace_period_secs = …Run Code Online (Sandbox Code Playgroud) 我想根据索引在张量中分配值.
例如,根据池值和tf.nn.max_pool_with_argmax的相应索引输出,我想将这些池值重新放回到具有索引的原始拆分Tensor中.
我发现输出指数tf.nn.max_pool_with_argmax是扁平的.一个问题:如何将它们解开回Tensorflow中的坐标?
另一个问题:如果给出索引,如何将池化张量的每个值分配给Tensorflow中原始解析张量的位置?
非常感谢你.
我试图制作代码来实现这一点,但我可以使用numpy.我不知道如何tf.nn.max_pool_with_argmax在Tensorflow中分配到unpooling张量之后获得平坦的索引.
ksize = 3
stride = 1
input_image = tf.placeholder(tf.float32, name='input_image')
#conv1
kernel = tf.Variable(tf.truncated_normal([ksize, ksize, 3, 16],stddev=0.1),
name='kernel')
conv = tf.nn.conv2d(input_image, kernel, [1,stride,stride,1], padding='SAME')
biases = tf.Variable(tf.constant(0.0, shape = [16]), name = 'biases')
bias = tf.nn.bias_add(conv, biases)
conv1 = tf.nn.relu(bias, name='conv1')
#pool1
pool1, pool1_indices = tf.nn.max_pool_with_argmax(conv1, ksize=[1, 2, 2, 1],
strides=[1, 2, 2, 1],
padding='SAME', name='pool1')
#upsample by assigning the values of pool1 to the position …Run Code Online (Sandbox Code Playgroud) 我有一个我无法找到原因的错误.这是代码:
with tf.Graph().as_default():
global_step = tf.Variable(0, trainable=False)
images = tf.placeholder(tf.float32, shape = [FLAGS.batch_size,33,33,1])
labels = tf.placeholder(tf.float32, shape = [FLAGS.batch_size,21,21,1])
logits = inference(images)
losses = loss(logits, labels)
train_op = train(losses, global_step)
saver = tf.train.Saver(tf.all_variables())
summary_op = tf.merge_all_summaries()
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
summary_writer = tf.train.SummaryWriter(FLAGS.train_dir, sess.graph)
for step in xrange(FLAGS.max_steps):
start_time = time.time()
data_batch, label_batch = SRCNN_inputs.next_batch(np_data, np_label,
FLAGS.batch_size)
_, loss_value = sess.run([train_op, losses], feed_dict={images: data_batch, labels: label_batch})
duration = time.time() - start_time
def next_batch(np_data, np_label, batchsize,
training_number = …Run Code Online (Sandbox Code Playgroud) 我遇到一个问题:在我使用tf.nn.max_pool_with_argmax之后,我获得了索引,即
argmax: A Tensor of type Targmax. 4-D. The flattened indices of the max values chosen for each output.
如何将展平的索引解开回Tensorflow中的坐标列表?
非常感谢你.
我有一个大小的hdf5训练数据集(21760, 1, 33, 33).21760是整个培训样本数量.我想使用大小的小批量训练数据128来训练网络.
我想问一下:
如何128从每个具有张量流的整个数据集中提供小批量训练数据?
我想使用cx_freeze将我的hello_world.py更改为exe文件.
当我像这样运行cxfreeze时:
cxfreeze hello_world.py
Run Code Online (Sandbox Code Playgroud)
我运行exe文件,它出现错误:
./hello_world
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
File "/home/karl/anaconda3/lib/python3.6/encodings/__init__.py", line 31, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
我想实现本文中介绍的空间金字塔池化层。
正如论文设置,关键点是定义 max_pooling 层的变体内核大小和步幅大小,即:
kernel_size = ceil(a/n)
stride_size = floor(a/n)
Run Code Online (Sandbox Code Playgroud)
其中a是输入张量空间大小,n是金字塔级别,即池化输出的空间箱。
我尝试用张量流实现这一层:
import numpy as np
import tensorflow as tf
def spp_layer(input_, name='SPP_layer'):
"""
4 level SPP layer.
spatial bins: [6_6, 3_3, 2_2, 1_1]
Parameters
----------
input_ : tensor
name : str
Returns
-------
tensor
"""
shape = input_.get_shape().as_list()
with tf.variable_scope(name):
spp_6_6_pool = tf.nn.max_pool(input_,
ksize=[1,
np.ceil(shape[1]/6).astype(np.int32),
np.ceil(shape[2]/6).astype(np.int32),
1],
strides=[1, shape[1]//6, shape[2]//6, 1],
padding='SAME')
print('SPP layer level 6:', spp_6_6_pool.get_shape().as_list())
spp_3_3_pool = tf.nn.max_pool(input_,
ksize=[1,
np.ceil(shape[1]/3).astype(np.int32),
np.ceil(shape[2]/3).astype(np.int32), …Run Code Online (Sandbox Code Playgroud) Spyder python IDE中是否有任何快捷键来缩进代码块?例如,ctr+[在Matlab中,我想将代码块缩进到一起.