Sequential neural network training with 1-D function layer

I'm trying to run a sequential neural network with input shape "ST". I have made a function layer, containing findpeaks. I'd like to perform findpeaks on the first dimension. When I try running the neural network, it tries to batch the data so that a 2-d SxT dlarray is passed into findpeaks, but findpeaks only accepts vectors as input.
Is my only option to put it into a for loop, or is there a way to parallelise it?
Thanks in advance.

2 Commenti

Matt J
Matt J il 4 Set 2026 alle 12:29
Modificato: Matt J il 4 Set 2026 alle 14:02
That doesn't appear to be your biggest problem. Your biggest problem is that the operations allowed in a functionLayer are restricted to the those compatible with dlarray input,
But findpeaks is not in the list of supported functions for dlarrays,
Nor does it seem to me that it ever could be. A findpeaks operations is not obviously differentiable in any way.
Unless for some reason findpeaks is not intended to be part of the differentiable chain of operations done by the network, I think you probably need a different approach to whatever you are doing.
Jeffery
Jeffery circa 6 ore fa
Modificato: Jeffery circa 4 ore fa
Thanks Matt,
I'm using it more as a feature extraction layer, so I'm not expecting any gradients to pass through it at all. The only alternative I can think of is to do the feature extraction before passing the data into the network. The problem with that is I'm still using the raw data as well, for another "branch" of the network. Meaning I'd have to change to a multi-head network, but sequential networks can't have multiple heads (yet? Would be a good addition as it feels like an arbitrary restriction).
Besides that the neural network works and trains if I pass inputs one at a time.
TLDR, it's more of a pre-processing thing that I don't think can be moved to outside of the neural network, and it works fine until I try to pass in a multi-dimensional input.

Accedi per commentare.

 Risposta accettata

You could try islocalmax instead, if a mask of the maxima locations is sufficient.

Più risposte (0)

Categorie

Prodotti

Release

R2023a

Richiesto:

il 4 Set 2026 alle 11:38

Risposto:

circa 4 ore fa

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by