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 commentaires

Matt J
Matt J le 4 Sep 2026 à 12:29
Modifié(e) : Matt J le 4 Sep 2026 à 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 il y a environ 4 heures
Modifié(e) : Jeffery il y a environ 2 heures
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Centre d'aide et File Exchange

Produits

Version

R2023a

Question posée :

le 4 Sep 2026 à 11:38

Modifié(e) :

il y a environ 2 heures

Community Treasure Hunt

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

Start Hunting!

Translated by