<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Ask Ghassem - Recent questions tagged neural-network</title>
<link>https://ask.ghassem.com/tag/neural-network</link>
<description>Powered by Question2Answer</description>
<item>
<title>I cannot get this code to work. please help.</title>
<link>https://ask.ghassem.com/1018/i-cannot-get-this-code-to-work-please-help</link>
<description>&lt;p&gt;from keras.models import Sequential&amp;nbsp;&lt;br&gt;
from keras.layers import Dense&amp;nbsp;&lt;br&gt;
from keras.layers import LSTM&amp;nbsp;&lt;br&gt;
from sklearn.model_selection import train_test_split&lt;/p&gt;

&lt;p&gt;model = Sequential()&amp;nbsp;&lt;br&gt;
model.add(LSTM( 10, input_shape=(1, 1)))&amp;nbsp;&lt;br&gt;
model.add(Dense(1, activation=&quot;linear&quot;))&amp;nbsp;&lt;br&gt;
model.compile(loss=&quot;mse&quot;, optimizer=&quot;adam&quot;)&lt;/p&gt;

&lt;p&gt;X, y = get_data()&lt;/p&gt;

&lt;p&gt;X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=1)&lt;br&gt;
X_train_2, X_val, y_train_2, y_val = train_test_split(X_train, y_train, test_size=0.25, random_state=1)&lt;/p&gt;

&lt;p&gt;model.fit(X_train, y_train, epochs=800, validation_data=(X_val, y_val), shuffle=False)&lt;/p&gt;
html, body, table, thead, input, textarea, select {color: #bab5ab!important; background: #35393b;} input[type=&quot;text&quot;], textarea, select {color: #bab5ab!important; background: #35393b;} [data-darksite-inline-background-image-gradient] {background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))!important; -webkit-background-size: cover!important; -moz-background-size: cover!important; -o-background-size: cover!important; background-size: cover!important;} [data-darksite-force-inline-background] * {background-color: rgba(0,0,0,0.7)!important;} [data-darksite-inline-background] {background-color: rgba(0,0,0,0.7)!important;} [data-darksite-inline-color] {color: #fff!important;} [data-darksite-inline-background-image] {background-image: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3))!important}
</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/1018/i-cannot-get-this-code-to-work-please-help</guid>
<pubDate>Mon, 21 Mar 2022 05:59:53 +0000</pubDate>
</item>
<item>
<title>How to update the weights in backpropagation algorithm when activation function in not linear?</title>
<link>https://ask.ghassem.com/901/update-weights-backpropagation-algorithm-activation-function</link>
<description>&lt;p&gt;The goal of backpropagation is to optimize the weights so that the neural network can learn how to correctly map arbitrary inputs to outputs.&lt;/p&gt;

&lt;p&gt;Assume for the following neural network, inputs = [$i_1,i_2$] = [0.05,&amp;nbsp;0.10], we want the neural network to output = [$o_1$,$o_2$] = [0.01,&amp;nbsp;0.99], and&amp;nbsp;for learning rate, $\alpha=0.5$.&lt;br&gt;
In addition, the activation function for the hidden layer (both $h_1$ and $h_2$)&amp;nbsp;is sigmoid (logistic):&lt;/p&gt;

&lt;p&gt;$S(x)=\frac{1}{1+e^{-x}}$&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/cnY5feu.png&quot;&gt;https://i.imgur.com/cnY5feu.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hint:&lt;/strong&gt;&lt;br&gt;
$w_{new} = w_{old} - \alpha \frac{\partial E}{\partial w}$&lt;/p&gt;

&lt;p&gt;$E_{\text {total}}=\sum \frac{1}{2}(\text {target}-\text {output})^{2}$&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;a) &lt;/strong&gt;Show step by step solution to&amp;nbsp;calculate weights $w_1$ to $w_8$ after one update in table below.&lt;br&gt;
&lt;strong&gt;b) &lt;/strong&gt;Calculate initial error and error after one update (assume&amp;nbsp;biases $[b_1,b_2]$ are not changing during the updates).&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot;&gt;
&lt;caption&gt;Updating weights in backpropagation algorithm&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Weights&lt;/td&gt;
&lt;td&gt;Initialization&lt;/td&gt;
&lt;td&gt;New weights after one step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w1$&lt;/td&gt;
&lt;td&gt;0.15&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w2$&lt;/td&gt;
&lt;td&gt;0.20&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w3$&lt;/td&gt;
&lt;td&gt;0.25&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w4$&lt;/td&gt;
&lt;td&gt;0.30&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w5$&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w6$&lt;/td&gt;
&lt;td&gt;0.45&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w7$&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w8$&lt;/td&gt;
&lt;td&gt;0.55&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/901/update-weights-backpropagation-algorithm-activation-function</guid>
<pubDate>Mon, 10 Aug 2020 21:55:19 +0000</pubDate>
</item>
</channel>
</rss>