Skip to content

Support for a concatenate layer #211

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

Open
jvdp1 opened this issue Feb 27, 2025 · 4 comments
Open

Support for a concatenate layer #211

jvdp1 opened this issue Feb 27, 2025 · 4 comments

Comments

@jvdp1
Copy link
Collaborator

jvdp1 commented Feb 27, 2025

State-of-the-art:

@milancurcic
Copy link
Member

Looks like the implementation would be straightforward. What are some uses of this?

@jvdp1
Copy link
Collaborator Author

jvdp1 commented Apr 14, 2025

In my context I have two types of input (DNA samples and environmental factors). I would like to investigate different types of layers (CNN for DNA and Dense for environmental factors).

@jvdp1
Copy link
Collaborator Author

jvdp1 commented Apr 30, 2025

As discussed here is a potential example:

  !Define the Convolutional network branch for the feature 1
  net_feat1 = network([ &
    input(ninput1), &
    reshape([1,28,28]), &
    conv1d(filters=8, kernel_size=3, activation=relu()), &
    maxpool1d(pool_size=2), &
    dense(64, activation=relu()) &
  ])

  !Define the Dense network branch for the feature 2
  net_feat2 = network([ &
    input(ninput2), &
    dense(32, activation=relu()) &
  ])

  !Combine the outputs of the two network branches and define the final dense layers for predi
ction
  net_combi = network([&
    input = concatenate(net_feat1%predict(), net_feat2%predict()), &
    dense(64, activation=relu(), &
    dense(1, activation=linear()) &
  ])

  !Train the model including its two branches
  epochs: do n = 1, num_epochs

    call net_combi % train( &
      input = [input%features1, input%features2], &  !could be a single array
      output_data, &
      batch_size=32, &
      epochs=1 &
    )

Prior art: Keras concatanate

@milancurcic
Copy link
Member

Thanks, Jeremie, that's clear!

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

No branches or pull requests

2 participants