I am facing floating point resolution loss during convolution operation while porting the code on my embedded processor which supports only half precision, so I want to test the intermediate operations that are performed layer by layer in my Keras based model which is performing good while on Full precision on my desktop.

In the following snippet of code I want to compute the 1DConv on the 1500x3 shaped input data. The kernel size is 10 and Kernel shape is (10x3x16).

To compute the 1D-Convolution, Keras does the Expand Dimensions on input shape and add one more dimension to it, which becomes suitable for 2D Convolution operation.

Then series of operations are called e.g. Conv2D followed by Squeeze and finally BiasAdd. Finally the output of the Conv1D layer is pushed in conv1d_20/Elu layer.

Please find the picture attached for full description of operations involved.

Now, I want to test the output much before the actual output of a Layer is produced.

Please see the below code:

Input_sequence = keras.layers.Input(shape=(1500,3))
encoder_conv1 = keras.layers.Conv1D(filters=16, kernel_size=10, padding='same', activation=tf.nn.elu)(Input_sequence)

The Model summary shows:

Model: "model_5"
Layer (type)                 Output Shape              Param #   
input_5 (InputLayer)         [(None, 1500, 3)]         0         
conv1d_20 (Conv1D)           (None, 1500, 16)          496  

I want to define the model output at conv1d_20/Conv2D but it gives me error. But the below is accepted at compilation.

encoder = keras.Model(inputs=autoencoder.input, outputs=autoencoder.get_layer('conv1d_20').output)

It outputs

<tf.Tensor 'conv1d_20/Elu:0' shape=(?, 1500, 16) dtype=float32>

I want to test the output of Conv2D operation but it produces the output of conv1d_20/Elu.

How can I do this test. Please help me.

Conv1D operation

New contributor
Arunav Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Arunav Kumar is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.