How to custom conv2D layer Keras using calculated values
This is my first question, Hello World I guess.
I need to create a conv2D custom layer (at least, I think so), which should use my custom module for extracting values in the first layer. It would be something like this:
model.add(CustomConv2D( 128? ,16, padding='valid',strides=16,
input_shape=(128, 128, 1)))
So, the thing is, my module looks something like this -- CustomModule.stuff(image) - This returns an np array with size 8.
I would like to pass that custom stuff for every $16*16$ window of my image, then processing it using my overkill-looking CNN.
model = models.Sequential()
model.add(layers.Conv2D(128,(5,5), padding='valid',strides=[1, 1], #This should be the custom layer
input_shape=(128, 128,1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(256, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(512, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(1024, (3, 3), activation='relu'))
#Dense
model.add(layers.Flatten())
model.add(layers.Dense(1024, activation='relu'))
#model.add(layers.Dropout(0.2)) #I was supposed to put this in there, but I really do not know what to do
model.add(layers.Dense(512, activation='relu'))
model.add(layers.Dense(256, activation='relu'))
model.add(layers.Dense(128, activation='relu'))
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(32, activation='relu'))
model.add(layers.Dense(16, activation='relu'))
model.add(layers.Dense(8, activation='relu'))
model.add(layers.Dense(4, activation='relu'))
model.add(layers.Dense(2, activation='softmax'))
Note: If you could give some advice for my network architecture, I'd really apreciate it. Note 2: I'm trying to detect steganography (subtle bit changes on image) Note 3: I'm probably making some code mistakes, I'd like to fix theese Thanks.
Topic cnn convolutional-neural-network deep-learning
Category Data Science