小编ari*_*izz的帖子

Tensorflow:tf.nn.conv2d在哪里实际执行?

我对Tensorflow的实现感到好奇tf.nn.conv2d(...).要调用它,只需运行即可tf.nn.conv2d(...).然而,我正在试图看到兔子洞被执行的地方.代码如下(箭头表示它最终调用的函数):

tf.nn.conv2d(...) -> tf.nn_ops.conv2d(...) -> tf.gen_nn_ops.conv2d(...) -> _op_def_lib.apply_op("Conv2D", ...) -> ?
Run Code Online (Sandbox Code Playgroud)

我熟悉Tensorflow对LSTM的实现以及在人们认为合适的情况下轻松操作它们的能力.是conv2d()用Python编写的执行计算的函数,如果是,它在哪里?我可以看到步幅的执行位置和方式吗?

python machine-learning tensorflow

15
推荐指数
1
解决办法
4880
查看次数

Tensorflow:成本的张量列表

我正在尝试使用Tensor Flow中的LSTM.我在网上找到了一个教程,其中包含一组序列,目标函数由LSTM的最后一个输出和已知值组成.但是,我希望我的目标函数使用每个输出的信息.具体来说,我试图让LSTM学习一系列序列(即在一个句子中学习单词中的所有字母):

cell = rnn_cell.BasicLSTMCell(num_units)
inputs = [tf.placeholder(tf.float32,shape=[batch_size,input_size]) for _ in range(seq_len)]
result = [tf.placeholder(tf.float32, shape=[batch_size,input_size]) for _ in range(seq_len)]

W_o = tf.Variable(tf.random_normal([num_units,input_size], stddev=0.01))     
b_o = tf.Variable(tf.random_normal([input_size], stddev=0.01))

outputs, states = rnn.rnn(cell, inputs, dtype=tf.float32)   

losses = []

for i in xrange(len(outputs)):
    final_transformed_val = tf.matmul(outputs[i],W_o) + b_o
    losses.append(tf.nn.softmax(final_transformed_val))

cost = tf.reduce_mean(losses) 
Run Code Online (Sandbox Code Playgroud)

这样做会导致错误:

TypeError: List of Tensors when single Tensor expected
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?是否tf.reduce_mean()采用张量值列表,还是有一些特殊的张量对象需要它们?

python list machine-learning tensorflow

5
推荐指数
1
解决办法
7643
查看次数

Tensorflow:3D卷积NN的对角线Subtensor

Theano使用2D CNN变体的3D卷积神经网络(CNN)解决方法:

https://github.com/Theano/Theano/blob/master/theano/tensor/nnet/conv3d2d.py

它依赖于能够抓住矩阵的对角线并重塑它.从上面的网站:

So the relevant part of `x` is some matrix `u`. Suppose it has 7 rows
and 4 columns::
    [ 0 0 0 0 ]
    [ 0 0 0 0 ]
    [ 0 0 0 0 ]
    [ 0 0 0 0 ]
    [ 0 0 0 0 ]
    [ 0 0 0 0 ]

The view returned by this function is also a matrix. It is a thick,
diagonal `stripe` across u that discards the lower …
Run Code Online (Sandbox Code Playgroud)

python machine-learning theano tensorflow

5
推荐指数
0
解决办法
831
查看次数

标签 统计

machine-learning ×3

python ×3

tensorflow ×3

list ×1

theano ×1