<p>as far as I can see there is a problem in your third line of code. <code>input_shape</code> should be the shape of the input to the network, not the shape of your training data.
If your training data has the shape of 5x50 you would have 5 training samples in your dataset.
For this to work your input has to be 50:</p>
<pre><code>model = Sequential([Dense(1, input_shape=[50])])
</code></pre>
<p>Now with <code>model.summary()</code> you can check that the input of your network is <code>(None, 50)</code>.</p>
<p>Also note that in a neural network, each neuron has an activation function.
Depending on the activation function <span class="math-container">$f(z)$</span> , the output would be <span class="math-container">$y = f(b+W^TX)$</span> which is not the same as linear regression.</p>
<p>Hope this helps!</p>

CC BY-SA 4.0
2021-07-21T12:48:02.593Z
2021-07-21T12:48:02.593Z
Heckspoiler
<p>I am trying to build a Deep Learning model that takes a numeric vector <span class="math-container">$X$</span> of dimension <span class="math-container">$1 \times 50$</span> and predicts a numeric vector <span class="math-container">$y$</span> of dimension <span class="math-container">$1 \times 50$</span>.</p>
<p>It's a linear regression problem. I am trying to achieve the coefficients/weights that can help me</p>
<p>Code I used:</p>
<pre><code>X = np.array(...) // array of 50 features and 5 sample vectors (shape of X is 5x50)
y = np.array(...) // array of 50 features (shape of y is 5x50)
model = Sequential([Dense(1, input_shape=[5,50])])

optimizer = Adam(0.001)

model.compile(loss='mse', optimizer=optimizer, metrics=['mae', 'mse'])

model.fit(X,y, epochs=250, validation_split=0.25))

</code></pre>
<p>So, basically we are achieving <code>X*w ~ y</code> where <span class="math-container">$w$</span> is the weights/coefficients that we want to identify using DL.</p>
<p>Programmatically, I tried using the same logic and calculated <span class="math-container">$w = y . X^{-1}$</span> for all the vectors. Took average of the coeff and applied on the test data.</p>

CC BY-SA 4.0
2021-07-20T22:48:20.547Z
What exactly is your doubt? Are you asking whether your procedure is correct or nor?
hanugm
CC BY-SA 4.0
2021-07-21T08:08:13.173Z
I am asking for procedure on how to achieve it as I am unable to achieve proper results.
Mowgli
<deep-learning><python>
Train a deep learning model with input as a vector and predicts as a vector?
Mowgli
# Train a deep learning model with input as a vector and predicts as a vector?

(Asked by: username_0 on 2021-07-20)

I am trying to build a Deep Learning model that takes a numeric vector $X$ of dimension $1 \times 50$ and predicts a numeric vector $y$ of dimension $1 \times 50$.
It's a linear regression problem. I am trying to achieve the coefficients/weights that can help me
Code I used:
X = np.array(...) // array of 50 features and 5 sample vectors (shape of X is 5x50)
y = np.array(...) // array of 50 features (shape of y is 5x50)
model = Sequential([Dense(1, input_shape=[5,50])])

optimizer = Adam(0.001)

model.compile(loss='mse', optimizer=optimizer, metrics=['mae', 'mse'])

model.fit(X,y, epochs=250, validation_split=0.25))


So, basically we are achieving X*w ~ y where $w$ is the weights/coefficients that we want to identify using DL.
Programmatically, I tried using the same logic and calculated $w = y . X^{-1}$ for all the vectors. Took average of the coeff and applied on the test data.

**Tags:** deep-learning, python

> **Comments:**
> **username_1**: What exactly is your doubt? Are you asking whether your procedure is correct or nor?  
> **username_0**: I am asking for procedure on how to achieve it as I am unable to achieve proper results.  

---

## 1 answers

### Answer by username_2 on 2021-07-21. Score: 0 | Accepted answer

as far as I can see there is a problem in your third line of code. input_shape should be the shape of the input to the network, not the shape of your training data.
If your training data has the shape of 5x50 you would have 5 training samples in your dataset.
For this to work your input has to be 50:
model = Sequential([Dense(1, input_shape=[50])])

Now with model.summary() you can check that the input of your network is (None, 50).
Also note that in a neural network, each neuron has an activation function.
Depending on the activation function $f(z)$ , the output would be $y = f(b+W^TX)$ which is not the same as linear regression.
Hope this helps!


---

