How can I generalize a machine learning model to multiple curves?

I have a family of convergence curves as you can see in the image below:

I would like to train a model that fits reasonably well to all the curves at the same time in my dataset. Is it possible? Do you have any suggestion? It could be a classical econometric model or even machine learning / deep learning models.

• What are your findings so far?
– nbro
Jun 4 at 7:47
• Please, also describe why you need to fit a model to multiple curves. What is your specific problem?
– nbro
Jun 4 at 18:32
• I need to generalize an optimization for numerical solution of an equation. Each solution follows one of these curves, so I need to generalize this solution of optimization to all these multiple curves. More specifically, the model should work fine for whatever the parameters of my equation are, which will result in different curves like the ones shown. Jun 4 at 22:58
– nbro
Jun 4 at 23:35
• One thing that comes to mind that could be useful in your case is the Gaussian process. Right now, I don't have time to explain more, but you can look it up here distill.pub/2019/visual-exploration-gaussian-processes. Once you have an answer to your question, feel free to write it below for future reference.
– nbro
Jun 4 at 23:47

This looks like a 1-to-many problem.

Given a single scalar x value, you want your output to be an array of size N where N is the number of curves.

as an example you can build a model in this way using tensorflow:

#====================== Build achitecture:
import tensorflow as tf
Input = tf.keras.layers.Input(shape=(1),name='Input')  #<<--- Takes a single scaler input
xi = tf.keras.layers.Dense(units=100,activation='relu',name='D1')(Input)
xi = tf.keras.layers.Dense(units=100,activation='relu',name='D2')(xi)
Output = tf.keras.layers.Dense(units=10,activation='relu',name='Output')(xi) #<<-- 1 unit for each output

model = tf.keras.Model(Input,Output,name='Model1')


Here is a visualizations of the results:

You can view the entire notebook here if you need it.

Hope this helps :)

• I have a question: in your approach, does this scalar somehow identify the curve that will be plotted? I ask this because as I said and a previous comment I need to generalize an optimization for numerical solution of an equation. So if somehow the paremters of the function, in your case s and k could identify the curve, it would be awesome! Jun 22 at 21:47
• So for an input tensor X of shape (n_samples,) you get an output tensor Y of shape (n_samples, m_functions) so if you want to access the output of just the kth function you could slice it: Y_k = Y[ : ,k]. We could have trained the model such that the input tensor X is of shape (n_samples,2) where each sample is a 1d tensor of size 2: [x_value, function_id] then you would just get an output of size (n_samples). I had taken the stipulation " ... fits reasonably well to all the curves at the same time" to mean you wanted all outputs simultaneously. Jun 28 at 3:39