张量流跟踪不起作用

时间:2016-04-19 21:08:05

标签: python tensorflow

我是Tensorflow的新手。我的张量x如下:

>>> x.eval()
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]], dtype=int32)

我想计算这个张量的跟踪,所以我使用tf.trace,但它会抛出错误:

>>> tf.trace(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'trace'

我该如何解决?非常感谢

1 个答案:

答案 0 :(得分:1)

为我工作

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<form>
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <div class="form-group">
    <label for="exampleInputFile">File input</label>
    <input type="file" id="exampleInputFile">
    <p class="help-block">Example block-level help text here.</p>
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox"> Check me out
    </label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

打印

import tensorflow as tf
x = tf.constant([[1, 2, 3],[4, 5, 6],[7, 8, 9]], dtype=tf.int32)
sess = tf.InteractiveSession()
x.eval()
tf.trace(x).eval()