Reputation: 341
Is there any way that I can try to modify ResNet50 and VGG16 where my data(spectograms) is of the shape (64,256,2)?
I understand that I can take some layers out and modify them(output, dense) but I am not really sure for input channels.
Can anyone suggest a way to accommodate 2 channels in the models? Help is much appreciated!
Upvotes: 1
Views: 1160
Reputation: 1377
You can use a different number of channels in the input (and a different height and width), but in this case, you cannot use the pretrained imagenet weights. You have to train from scratch. You can create them as follows:
from tensorflow import keras # or just import keras
vggnet = keras.applications.vgg16.VGG16(input_shape=(64,256,2), include_top=False, weights=None)
Note the weights=None
argument. It means initialize weights randomly. If you have number of channels set to 3
, you could use weights='imagenet'
, but in your case, you have 2 channels, so it won't work and you have to set it to None
. The include_top=False
is there for you to add final classification layers with different categories yourself. You could also create vgg19.VGG19
in the same way. For ResNet, you could similarly create it as follows:
resnet = keras.applications.resnet50.ResNet50(input_shape=(64, 256, 2), weights=None, include_top=False)
For other models and versions of vgg and resnet, please check here.
Upvotes: 1