cog-imperial / OMLT

Represent trained machine learning models as Pyomo optimization formulations
Other
257 stars 56 forks source link

Support for max pooling layers #91

Closed adi4656 closed 1 year ago

adi4656 commented 1 year ago

This code adds support for formulating max pooling layers into OMLT, using the formulation in Anderson et al. (2020). Changes are made in the io directory to parse ONNX max pool nodes; in neuralnet/layer.py to add a layer class for arbitrary pooling operations; in neuralnet/layers/full_space.py to add the Anderson formulation of max pooling; and in the relevant test programs.

Legal Acknowledgement\ By contributing to this software project, I agree my contributions are submitted under the BSD license. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

adi4656 commented 1 year ago

I have added the changes discussed on Monday's meetings. The checks will still fail due to the unresolved issue around reshaping inputs before evaluating them.

codecov[bot] commented 1 year ago

Codecov Report

Merging #91 (6458258) into main (d363f10) will increase coverage by 0.89%. The diff coverage is 98.42%.

@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   94.19%   95.08%   +0.89%     
==========================================
  Files          25       25              
  Lines        1240     1364     +124     
  Branches      192      189       -3     
==========================================
+ Hits         1168     1297     +129     
+ Misses         42       37       -5     
  Partials       30       30              
Impacted Files Coverage Δ
src/omlt/neuralnet/layer.py 91.97% <97.43%> (+1.39%) :arrow_up:
src/omlt/io/onnx_parser.py 97.14% <98.03%> (+2.14%) :arrow_up:
src/omlt/neuralnet/activations/__init__.py 100.00% <100.00%> (ø)
src/omlt/neuralnet/activations/relu.py 96.77% <100.00%> (ø)
src/omlt/neuralnet/layers/__init__.py 100.00% <100.00%> (ø)
src/omlt/neuralnet/layers/full_space.py 100.00% <100.00%> (ø)
src/omlt/neuralnet/nn_formulation.py 92.92% <100.00%> (ø)
src/omlt/neuralnet/layers/partition_based.py 94.02% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

adi4656 commented 1 year ago

PR now passes all checks and (I think) I have resolved the issues raised by everyone ;) @rmisener