1 回答
TA贡献1796条经验 获得超4个赞
Conv2D需要 4D 输入,您无法更改它。我不太确定你想要完成什么,但你可以使用Conv3D:
from tensorflow.keras.layers import *
from tensorflow.keras.models import Sequential
import tensorflow as tf
model = Sequential([
Input(shape=(None, 128, 128, 1)),
Conv3D(32, kernel_size=(1, 3, 3)),
Flatten()
])
multiple_images = tf.random.uniform((10, 10, 128, 128, 1), dtype=tf.float32)
model(multiple_images)
<tf.Tensor: shape=(10, 5080320), dtype=float32, numpy=
array([[-0.26742983, -0.09689523, -0.12120364, ..., -0.02987139,
0.05515741, 0.12026916],
[-0.18898709, 0.12448274, -0.17439063, ..., 0.23424357,
-0.06001307, -0.13852882],
[-0.14464797, 0.26356792, -0.34748033, ..., 0.07819699,
-0.11639086, 0.10701762],
...,
[-0.1536693 , 0.13642962, -0.18564 , ..., 0.07165999,
-0.0173855 , -0.04348694],
[-0.32320747, 0.09207243, -0.22274591, ..., 0.11940736,
-0.02635285, -0.1140241 ],
[-0.21126074, -0.00094431, -0.10933039, ..., 0.06002581,
-0.09649743, 0.09335127]], dtype=float32)>
添加回答
举报