如果不允许迭代,请在张量中找到内容

发布于 2025-01-27 13:15:14 字数 1411 浏览 1 评论 0原文

我一直在尝试在点云中扩展X和Y坐标的张量,以查看其内容,但我所能获得的只是张量及其类型的形状。

(像这样的东西:

x_interior_1 = domain_invar['Interior1']['x']
print(x_interior_1)
y_interior_1 = domain_invar['Interior1']['y'] 
print(y_interior_1)

结果

Tensor("x_2:0", shape=(10000, 1), dtype=float32)
Tensor("y_2:0", shape=(10000, 1), dtype=float32)

:)

当我在迭代器上运行迭代器时,不允许迭代。

tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: iterating over `tf.Tensor` is not allowed in Graph execution. 
Use Eager execution or decorate this function with @tf.function.

所以我这样做。我把装饰符放在防守上方。但是,然后我对此表示欢迎:

  @tf.function
  def custom_loss(self, domain_invar, pred_domain_outvar, true_domain_outvar, step):
    # get points on interior of rec
    x_interior_1 = domain_invar['Interior1']['x']
    print([x for x in x_interior_1])
    y_interior_1 = domain_invar['Interior1']['y']
    print([y for y in y_interior_1])
    area_interior_1 = domain_invar['Interior1']['area']
    x_interior_2 = domain_invar['Interior2']['x']
    y_interior_2 = domain_invar['Interior2']['y']
    area_interior_2 = domain_invar['Interior2']['area']

结果:

    return _pywrap_tensorflow_internal.Flatten(nested, expand_composites)
    TypeError: '<' not supported between instances of 'Key' and 'Key'

看到里面有什么?

I have been trying to expand a tensor of x and y coordinates in a point cloud to see it's contents, but all I can get is the shape of the tensor and its type.

(Something like this :

x_interior_1 = domain_invar['Interior1']['x']
print(x_interior_1)
y_interior_1 = domain_invar['Interior1']['y'] 
print(y_interior_1)

Result:

Tensor("x_2:0", shape=(10000, 1), dtype=float32)
Tensor("y_2:0", shape=(10000, 1), dtype=float32)

)

When I run an iterator over it, I'm greeted with iteration not allowed.

tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: iterating over `tf.Tensor` is not allowed in Graph execution. 
Use Eager execution or decorate this function with @tf.function.

So I do it. I put the decorator above the def. But then, I'm greeted with this:

  @tf.function
  def custom_loss(self, domain_invar, pred_domain_outvar, true_domain_outvar, step):
    # get points on interior of rec
    x_interior_1 = domain_invar['Interior1']['x']
    print([x for x in x_interior_1])
    y_interior_1 = domain_invar['Interior1']['y']
    print([y for y in y_interior_1])
    area_interior_1 = domain_invar['Interior1']['area']
    x_interior_2 = domain_invar['Interior2']['x']
    y_interior_2 = domain_invar['Interior2']['y']
    area_interior_2 = domain_invar['Interior2']['area']

Result:

    return _pywrap_tensorflow_internal.Flatten(nested, expand_composites)
    TypeError: '<' not supported between instances of 'Key' and 'Key'

What does one do to see what's inside??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文