hls4ml Global Average Pooling 1D Error

97 views
Skip to first unread message

Key, Kevin J.

unread,
Sep 8, 2021, 5:14:39 PM9/8/21
to hls4m...@gmail.com

Hello!

 

I am working with the hls4ml library and have a sequential model which does not compile when adding in a Global Average Pooling 1D layer. The model does compile and completes synthesis successfully without the Global Average Pooling 1D layer, but I would like to be able to add in the Global Average Pooling 1D layer at the end of my model. The error I receive is listed below, and I appreciate any help you can provide in fixing this error.

 

 

Best,

Kevin

 

Kevin J. Key

Radar & EW Systems Development

 

The Johns Hopkins University Applied Physics Laboratory

11100 Johns Hopkins Road

Laurel, MD 20723

 

(240) 592-4392

Kevi...@jhuapl.edu

 

Javier Duarte

unread,
Sep 10, 2021, 11:47:12 AM9/10/21
to hls4m...@googlegroups.com, Kevi...@jhuapl.edu
Dear Kevin,

Could you open an issue in GitHub and/or provide your model or a simple script to reproduce the issue? We should be able to fix it.

Thanks,

Javier

--
You received this message because you are subscribed to the Google Groups "hls4ml help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hls4mlhelp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hls4mlhelp/73a018cc180249e88ad3cc494ef5e217%40jhuapl.edu.

Key, Kevin J.

unread,
Sep 13, 2021, 10:25:43 AM9/13/21
to Javier Duarte, hls4m...@googlegroups.com

Hi Javier,

 

Thank you for getting back to me, I appreciate it! Attached is a .txt file with a simple python script which will reproduce the error. I also pasted the code below. Thanks for any help you can give!

 


from tensorflow.keras.models import Sequential

from tensorflow.keras.layers import Dense, Activation, BatchNormalization, Conv1D, Conv2D, Dropout, GlobalAveragePooling2D, GlobalAveragePooling1D, MaxPooling1D, GlobalMaxPooling1D

from tensorflow.keras.optimizers import Adam

 

in_shape = 32

out_shape = 4

 

model = Sequential()

 

model.add(Conv1D(filters=4, kernel_size=2, padding='same', input_shape=(in_shape, 2)))

 

model.add(Conv1D(filters=8, kernel_size=2, padding='same'))

 

model.add(Conv1D(filters=out_shape, kernel_size=2, padding='same'))

model.add(GlobalAveragePooling1D())

 

adam = Adam(lr=0.0001)

model.compile(optimizer=adam, loss=['categorical_crossentropy'], metrics=['accuracy'])

 

model.summary()

 

# Make an hls4ml config & model

import hls4ml

import plotting

config = hls4ml.utils.config_from_keras_model(model, granularity='name')

plotting.print_dict(config)

 

# Make Model

hls_model = hls4ml.converters.convert_from_keras_model(model,

    hls_config=config,

    io_type='io_stream',

    output_dir='hls4ml_help',

    fpga_part='xcvu9p-flgb2104-2-i')

hls4ml.utils.plot_model(hls_model, show_shapes=True, show_precision=True, to_file='model_plot.png')                                                

 

# Compile and predict

hls_model.compile()

 

# Synthesize

hls_model.build(csim=False)

 

# Reports

hls4ml.report.read_vivado_report('hls4ml_help')


 

Best,

Kevin

 

Kevin J. Key

Radar & EW Systems Development

 

The Johns Hopkins University Applied Physics Laboratory

11100 Johns Hopkins Road

Laurel, MD 20723

 

(240) 592-4392

www.jhuapl.edu

 

From: Javier Duarte <javier.m...@gmail.com>
Sent: Friday, September 10, 2021 11:47 AM
To: hls4m...@googlegroups.com; Key, Kevin J. <Kevi...@jhuapl.edu>
Subject: [EXT] Re: [hls4ml.help] hls4ml Global Average Pooling 1D Error

 

APL external email warning: Verify sender javier.m...@gmail.com before clicking links or attachments

 

image001.png
hls4ml_help_script.txt

Key, Kevin J.

unread,
Sep 20, 2021, 10:59:02 AM9/20/21
to Javier Duarte, hls4m...@googlegroups.com

Hi Javier,

 

Hope you’re doing well! I wanted to reach out and make sure you received my message below with the script to reproduce the error, thanks!

 

Best,

Kevin

 

Kevin J. Key

Radar & EW Systems Development

 

The Johns Hopkins University Applied Physics Laboratory

11100 Johns Hopkins Road

Laurel, MD 20723

 

(240) 592-4392

Best,

Kevin

 

Kevin J. Key

Radar & EW Systems Development

 

The Johns Hopkins University Applied Physics Laboratory

11100 Johns Hopkins Road

Laurel, MD 20723

 

(240) 592-4392

 

From: Javier Duarte <javier.m...@gmail.com>
Sent: Friday, September 10, 2021 11:47 AM
To: hls4m...@googlegroups.com; Key, Kevin J. <Kevi...@jhuapl.edu>
Subject: [EXT] Re: [hls4ml.help] hls4ml Global Average Pooling 1D Error

 

APL external email warning: Verify sender javier.m...@gmail.com before clicking links or attachments

 

Dear Kevin,

Javier Duarte

unread,
Sep 20, 2021, 11:35:54 PM9/20/21
to Key, Kevin J., hls4m...@googlegroups.com, jmit...@fnal.gov
Dear Kevin,

Sorry for the delay. We've started to look into the issue, creating both an issue: https://github.com/fastmachinelearning/hls4ml/issues/398 and a draft pull request (to be finished, validated, etc.): https://github.com/fastmachinelearning/hls4ml/pull/399

Please feel free to give that branch a try and let us know what you think.

Thanks,
Javier and Jovan
Reply all
Reply to author
Forward
0 new messages