Answers.Body: <p>This looks like a <em>1-to-many</em> problem.</p>
  <p>Given a single scalar x value, you want your output to be an array of size N where N is the number of curves.</p>
  <p>as an example you can build a model in this way using tensorflow:</p>
  <pre><code>#====================== Build achitecture:
  import tensorflow as tf
  Input = tf.keras.layers.Input(shape=(1),name='Input')  #&lt;&lt;--- 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) #&lt;&lt;-- 1 unit for each output
  
  model = tf.keras.Model(Input,Output,name='Model1')
  </code></pre>
  <p>Here is a visualizations of the results:</p>
  <p><a href="https://i.sstatic.net/yau0v.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yau0v.png" alt="enter image description here" /></a></p>
  <p>You can view the entire notebook <a href="https://github.com/delta2echo/StackOverflow_Responses/blob/main/One_To_Many.ipynb" rel="nofollow noreferrer"><strong>here</strong></a> if you need it.</p>
  <p>Hope this helps :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T21:47:47.737Z
Answers.Text: 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!
Answers.UserDisplayName: giovasbr
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-28T03:39:07.443Z
Answers.Text: 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.
Answers.UserDisplayName: J.Kent
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-05T06:09:16.997Z
Answers.LastActivityDate: 2022-06-05T06:09:16.997Z
Answers.UserDisplayName: J.Kent
Body: <p>I have a family of convergence curves as you can see in the image below:</p>
  <p><a href="https://i.sstatic.net/s0gO9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s0gO9.png" alt="enter image description here" /></a></p>
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-04T07:47:06.947Z
Comments.Text: What are your findings so far?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-04T18:32:43.053Z
Comments.Text: Please, also describe why you need to fit a model to multiple curves. What is your specific problem?
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-04T22:58:55.643Z
Comments.Text: 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.
Comments.UserDisplayName: giovasbr
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-04T23:35:58.327Z
Comments.Text: Please, edit your post to include those details directly there.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-04T23:47:03.933Z
Comments.Text: 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 https://distill.pub/2019/visual-exploration-gaussian-processes/. Once you have an answer to your question, feel free to write it below for future reference.
Comments.UserDisplayName: nbro
Tags: <machine-learning><deep-learning><model-request>
Title: How can I generalize a machine learning model to multiple curves?
UserDisplayName: giovasbr
ThreadText: # How can I generalize a machine learning model to multiple curves?
  
  (Asked by: username_0 on 2022-06-04)
  
  I have a family of convergence curves as you can see in the image below:
  
  [![enter image description here](https://i.sstatic.net/s0gO9.png)](https://i.sstatic.net/s0gO9.png)
  
  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.
  
  **Tags:** machine-learning, deep-learning, model-request
  > **Comments:**
  > **username_1**: What are your findings so far?  
  > **username_1**: Please, also describe why you need to fit a model to multiple curves. What is your specific problem?  
  > **username_0**: 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.  
  > **username_1**: Please, edit your post to include those details directly there.  
  > **username_1**: 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 https://distill.pub/2019/visual-exploration-gaussian-processes/. Once you have an answer to your question, feel free to write it below for future reference.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-06-05. Score: 1
  
  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 :)
  
  > **Comments:**
  > **username_0**: 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!  
  > **username_2**: 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.  
  
  ---
  
  