Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reshape the tensor in keras?

I want to reshape a tensor, it's shape is (?,12,12,5,512) into (?,12,12,2560) shape of tensor. Is there anyone who can help me? My code is as below.

conv5_1 = Conv3D(512, (3, 3, 3), activation='relu', padding='same')(drop4_1) # conv5_1: Tensor("conv3d_10/Relu:0", shape=(", 12, 12, 5, 512), dtype=float32)
conv5_1 = Conv3D(512, (3, 3, 3), activation='relu', padding='same')(conv5_1)
drop5_1 = Dropout(0.2)(conv5_1) # drop5_1: Tensor("dropout_8/cond/Merge:0", shape=(", 12, 12, 5, 512), dtype=float32)

I want to make (?, 12, 12, 2560) shape of tensor after drop5_1. Thanks

like image 834
Tom Avatar asked Jan 29 '23 11:01

Tom


1 Answers

keras.layers.core.Reshape() function is helpful (see also the document).

reshaped = Reshape((12, 12, 2560))(drop5_1)
like image 97
hikaru Avatar answered Feb 27 '23 06:02

hikaru