Skip to content

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
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Copy link
Collaborator

@Riccardo231 Riccardo231 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
@Riccardo231
Copy link
Collaborator

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