MSI
MSI

Reputation: 125

Reshape for Transfer learning

I am trying transfer learning I have data of input size (16657, 32, 32, 1) but I want to feed it into the model as input. I need a size of (16657, 32, 32, 3). How can I add 2 extra channels? though it's working fine in the conv2d model. but I want to apply it to other transfer learning models like vgg19,resnet50, etc.

Upvotes: 0

Views: 126

Answers (1)

thisisme
thisisme

Reputation: 34

You can just duplicate the existing channel into two additional dimensions. Use a preprocessing function on the input images before feeding them to the network and define the function to stack the channel 3 times.

img = np.array([[12, 16,19], [124,25,19], [76,8,78]]) # shape (3,3)
stacked_img = np.stack((img,)*3, axis=0) # shape (3,3,3)

Upvotes: 0

Related Questions