如果不允许迭代,请在张量中找到内容
我一直在尝试在点云中扩展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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论