2
$\begingroup$

I am currently trying to build a self adjusting network, such that given any number of inputs, should always provide an output of shape (15,145)

The network structure is pretty simple and looks like this:

    inputs = 36
    list_of_input = [Input(shape = (45,5,3)) for i in range(inputs)]
    list_of_conv_output = []
    list_of_max_out = []
    for i in range(splits):
        list_of_conv_output.append(Conv2D(filters = 145 , kernel_size = (30,3))(list_of_input[i]))
        list_of_max_out.append((MaxPooling2D(pool_size=(3,2))(list_of_conv_output[i])))

    merge = keras.layers.concatenate(list_of_max_out)
    #reshape = Reshape((merge.shape[0],merge.shape[3]))(merge)

    dense1 = Dense(units = 1000, activation = 'relu',    name = "dense_1")(merge)
    dense2 = Dense(units = 1000, activation = 'relu',    name = "dense_2")(dense1)
    dense3 = Dense(units = 145 , activation = 'softmax', name = "dense_3")(dense2)



    model = Model(inputs = list_of_input , outputs = dense3)
    model.compile(loss="sparse_categorical_crossentropy", optimizer="adam")

    print model.summary()

    raw_input("SDasd")
    hist_current = model.fit(x = [train_input[i] for i in range(100)],
                        y = labels_train_data,
                        shuffle=False,
                        validation_data=([test_input[i] for i in range(10)], labels_test_data),
                        validation_split=0.1,
                        epochs=150000,
                        batch_size = 15,
                        verbose=1)

It been adjusted for having 36 inputs which would given it an output shape of (15,1,145) - but how can i determine the number of filters, kernel size and pooling size that would give me the desired output size. The network is supposed to be used for classification, and the output vector of length 15 with classes for each third entry in the first axis (45 = 15*3). the total number of classes is 145, hence output dimension (15,145)

$\endgroup$

1 Answer 1

1
$\begingroup$

Spatial pyramid pooling layers (https://arxiv.org/pdf/1406.4729.pdf) should solve this problem for you. These layers allow you to use input images of any dimension, instead of being restricted to 224x224 images, for example.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.