小编Gau*_*uss的帖子

关于tensorflow元数据和RunOptions

当我使用tensorboard时,我找到了代码:

run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
Run Code Online (Sandbox Code Playgroud)

但我无法理解这段代码的含义,我试图搜索解释,但失败了.任何人都可以向我提供一些详细的材料或向我解释元数据和runoptions?元数据和runoptions的目的是什么?

tensorflow

10
推荐指数
2
解决办法
5038
查看次数

如何在主函数中使用 boost::python::dict 或元组?

当我在main函数中使用 boost::python::tuple 或 boost::python::dict 时,程序崩溃了!

#define BOOST_PYTHON_STATIC_LIB
#include <boost/python.hpp>
#include <iostream>
#include <boost/python/tuple.hpp>
#include <boost/python/dict.hpp>

//using namespace std;
using namespace boost::python;

int main()
{
    //tuple x;
    //x = make_tuple(object(0),object(1));
    dict x;
    x["123"] = 3;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是当我在 中使用它们时.dll,没关系,有什么问题?

boost-python

4
推荐指数
1
解决办法
3048
查看次数

tf.nn.moments如何计算方差?

看一下测试示例:

import tensorflow as tf

x = tf.constant([[1,2],[3,4],[5,6]])
mean, variance = tf.nn.moments(x, [0])
with tf.Session() as sess:
    m, v = sess.run([mean, variance])
    print(m, v)
Run Code Online (Sandbox Code Playgroud)

输出为:

[3 4]

[2 2]
Run Code Online (Sandbox Code Playgroud)

我们要计算沿轴0的方差,第一列是[1,3,5],并且均值=(1 + 3 + 5)/ 3 = 3,是的,方差= [(1-3) ^ 2 +(3-3)^ 2 +(5-3)^ 2] /3=2.6666,但输出为2,谁能告诉我如何tf.nn.moments 计算方差?

顺便说一下,查看API DOC,该怎么shift办?

tensorflow

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

关于tensorboard name_scope

我使用name_scope来管理变量的名称,因此它可以通过tensorboard很好地显示.但是我发现一些奇怪的东西,name_scope不会为tf.get_variable创建的变量添加前缀.所以代码引发了一个错误:

with tf.name_scope(self.networkName + '/conv1'):
    self.conv1_w = tf.get_variable(shape = [8, 8, 4, 16], name = 'w', initializer=tf.contrib.layers.xavier_initializer())
    self.conv1_b = tf.get_variable(shape = [16], name = 'b', initializer=tf.contrib.layers.xavier_initializer())
    self.conv1_o = tf.nn.relu(tf.nn.conv2d(self.states, self.conv1_w, [1, 4, 4, 1], 'SAME') + self.conv1_b)

with tf.name_scope(self.networkName + '/conv2'):
    self.conv2_w = tf.get_variable(shape = [4, 4, 16, 32], name = 'w', initializer=tf.contrib.layers.xavier_initializer())
    self.conv2_b = tf.get_variable(shape = [32], name = 'b', initializer=tf.contrib.layers.xavier_initializer())
    self.conv2_o = tf.nn.relu(tf.nn.conv2d(self.conv1_o, self.conv2_w, [1, 2, 2, 1], 'SAME') + self.conv2_b)
Run Code Online (Sandbox Code Playgroud)

ValueError:变量w已存在,不允许.

我可以使用variable_scope而不是name_scope吗?tensorboard可以在variable_scope上工作吗?

tensorflow tensorboard

0
推荐指数
1
解决办法
961
查看次数

标签 统计

tensorflow ×3

boost-python ×1

tensorboard ×1