简体   繁体   English

如何获得张量形状 python

[英]How to get tensor Shape python

I have an issue with tensors.我对张量有疑问。

X.get_shape() returns (?, ?, ?, 512)

Whereas when I try to concatenate X and an other vector X=Concatenate()([X,X_add]) , it raises the exception.而当我尝试连接 X 和另一个向量X=Concatenate()([X,X_add])时,它会引发异常。

A Concatenate layer requires inputs with matching shapes except for the concat axis. Concatenate层需要具有匹配形状的输入,连接轴除外。 Got inputs shapes: [(None, 32, 32, 512), (None, 256, 256, 64)]得到输入形状:[(None, 32, 32, 512), (None, 256, 256, 64)]

How do I get those shapes in order to use Cropp2D in my resnet.如何获得这些形状以便在我的 resnet 中使用 Cropp2D。

Sometimes you have to reshape tensors before concatenating.有时你必须在连接之前重塑张量。 But that won't solve your problem here, because the two tensors are of different size: 32*32*512.= 256* 256*64.但这并不能解决您的问题,因为这两个张量的大小不同:32*32*512.= 256* 256*64。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM