Skip to content

Unable to understand what to do with the output of im2col.py of this repo #5

@atifkarim

Description

@atifkarim

Hello, I am trying to follow your im2col code. My intention is to do the forward pass of an RGB image without using any framework API. Right now I am using Keras.

I have started i the following way --

1/ Extract the weight from the model using layer.get_weights()
2/ Then I have appended the output of layer.get_weights() in a list named layerdic
3/ I have assigned an array conv_kernel and stored here the value of layerdic[0][0] and another array named conv_bias where I have stored layerdic[0][1]. If I am not wrong conv_kernel stores the value of kernel weight and conv_bias stores the bias value which I need for convolution.
4/ Then I have assigned an input image in X_test array and has done the convolution with your code.

My query is now ---

1/ What is the significance of out and cache and where do I need these values for the next part of forward pass?
1/ How can I do the next calculation. For example, in my case I will do the Flatten and Dense for classification. How can I approach for this purpose?

I am giving below my model:

    model = Sequential()

    model.add(Conv2D(1, (3, 3), padding='same',
                     input_shape=(3, IMG_SIZE, IMG_SIZE),
                     activation='relu'))
    model.add(Flatten())
    model.add(Dense(NUM_CLASSES, activation='softmax'))
    
    return model

model = cnn_model()

lr = 0.01
sgd = SGD(lr=lr, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
          optimizer=sgd,
          metrics=['accuracy'])

Kindly please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions