I have a classifier (implemented in tensorflow 2.2) with a small input of float vectors shaped (None,500,1) and one hot output of (None,100). I want to train the same architecture when "Sliding" it across a larger vector: the input should be (None,5000) and output will be the outcome of its results over the large vector: (None,10,100) that will be aggregated with some function like average to get the one hot result (None,100). I wish to implement this inside the model without splitting the data vectors to several pieces.
#A small input simplified working model:
from tensorflow.keras.layers import Input,Conv1D,LSTM,Dense,Flatten
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
input_vector_length=500
output_size=100
filters, units,kernel_size=4,4,4
small_inp = Input((input_vector_length, 1))
x = Conv1D(filters, kernel_size=kernel_size, activation='relu')(small_inp)
x = LSTM(units, return_sequences=True)(x)
x = Flatten()(x)
preds= Dense(output_size, activation='softmax')(x)
model = Model(inputs=small_inp, outputs=preds)
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
#Generating data and training:
X=np.random.normal(size=(200,500,1))
labels=np.random.randint(0,100,(200,))
y=np.eye(100)[labels]
model.fit(X,y,epochs=5)