Skip to content

Generic conv & maxpool #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 2, 2025

Conversation

milancurcic
Copy link
Member

This PR makes conv1d and conv2d accessible under a generic name conv.

Same for maxpool, except that here we have to make stride a required argument due to interface ambiguity when it's optional.

An example CNN with the new API is now:

  net = network([ &
    input(784), &
    reshape(1, 28, 28), &
    conv(filters=8, kernel_width=3, kernel_height=3, activation=relu()), &
    maxpool(pool_width=2, pool_height=2, stride=2), &
    conv(filters=16, kernel_width=3, kernel_height=3, activation=relu()), &
    maxpool(pool_width=2, pool_height=2, stride=2), &
    dense(10, activation=softmax()) &
  ])

or, without keywords:

  net = network([ &
    input(784), &
    reshape(1, 28, 28), &
    conv(8, 3, 3), &
    maxpool(2, 2, 2), &
    conv(16, 3, 3), &
    maxpool(2, 2, 2), &
    dense(10, activation=softmax()) &
  ])

This is mainly a style choice; I can see pros and cons to either approach. I'm curious what you think.

Copy link
Collaborator

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Here are some suggestions

milancurcic and others added 4 commits April 25, 2025 10:25
Copy link
Collaborator

@ricor07 ricor07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@milancurcic milancurcic merged commit 402b84a into modern-fortran:main May 2, 2025
4 checks passed
@milancurcic milancurcic deleted the generic-conv-maxpool branch May 2, 2025 17:19
@ricor07
Copy link
Collaborator

ricor07 commented May 3, 2025

Great. Just to give an update, I started writing some code for my pr poolings but i think i'll be busy until June.

@milancurcic
Copy link
Member Author

@ricor07 no problem at all, whenever you're ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants