<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Advanced Keras &#8211; Custom loss functions	</title>
	<atom:link href="https://petaminds.com/advanced-keras-custom-loss-functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://petaminds.com/advanced-keras-custom-loss-functions/</link>
	<description>A.I, Data and Software Engineering</description>
	<lastBuildDate>Sat, 26 Mar 2022 02:11:59 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: Tung Nguyen		</title>
		<link>https://petaminds.com/advanced-keras-custom-loss-functions/#comment-80</link>

		<dc:creator><![CDATA[Tung Nguyen]]></dc:creator>
		<pubDate>Sat, 26 Mar 2022 01:47:48 +0000</pubDate>
		<guid isPermaLink="false">https://petaminds.com/?p=1391#comment-80</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://petaminds.com/advanced-keras-custom-loss-functions/#comment-78&quot;&gt;SUN&lt;/a&gt;.

When calculating the loss, the params are vectors with same dimens, e.g. y_pred, y_true, and b. The calculation happens at the end of the epoch.

It means they did not pass 1 by 1 like [x_train1, y_train1, b1]. They first passing x_train, y_train to train the model each epoch, then calculate: y_pred, y_true with b in the custom loss.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://petaminds.com/advanced-keras-custom-loss-functions/#comment-78">SUN</a>.</p>
<p>When calculating the loss, the params are vectors with same dimens, e.g. y_pred, y_true, and b. The calculation happens at the end of the epoch.</p>
<p>It means they did not pass 1 by 1 like [x_train1, y_train1, b1]. They first passing x_train, y_train to train the model each epoch, then calculate: y_pred, y_true with b in the custom loss.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: SUN		</title>
		<link>https://petaminds.com/advanced-keras-custom-loss-functions/#comment-78</link>

		<dc:creator><![CDATA[SUN]]></dc:creator>
		<pubDate>Wed, 23 Mar 2022 16:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://petaminds.com/?p=1391#comment-78</guid>

					<description><![CDATA[Good job! Learned a lot from your sharing.
Well, I am wondering how to pass different parameters from an array to the custom loss function. 
Let&#039;s say my toy model likes this

def my_mse_loss_b(b):
     def mseb(y_true, y_pred):
         return K.mean(K.square(y_pred - y_true)) + b
     return mseb

inputs = Input(shape=(200,))
x = Dense(128, activation=&#039;relu&#039;)(input)
x = Dense(200, activation=&#039;relu&#039;)(x)
outputs = Dense(200, activation=&#039;linear&#039;)(x)
model = Model(inputs=inputs, outputs=outputs)
model.compile(loss=my_mse_loss_b(B), optimizer=Adam(lr=0.0005))
history = model.fit(x_train, y_train, batch_size=64, epochs=2)

The shape of my x_train is (1000,200,1),  y_train is (1000,200), B is (1000,)
When x_train[0] and  y_train[0] pass to the training model, B[0] is passed as b, then x_train[1] and  y_train[1] pass to the trainingmodel, B[1] is passed as b
Is that possible?
Would you please give me a hint?
Thanks, have a nice day!]]></description>
			<content:encoded><![CDATA[<p>Good job! Learned a lot from your sharing.<br />
Well, I am wondering how to pass different parameters from an array to the custom loss function.<br />
Let&#8217;s say my toy model likes this</p>
<p>def my_mse_loss_b(b):<br />
     def mseb(y_true, y_pred):<br />
         return K.mean(K.square(y_pred &#8211; y_true)) + b<br />
     return mseb</p>
<p>inputs = Input(shape=(200,))<br />
x = Dense(128, activation=&#8217;relu&#8217;)(input)<br />
x = Dense(200, activation=&#8217;relu&#8217;)(x)<br />
outputs = Dense(200, activation=&#8217;linear&#8217;)(x)<br />
model = Model(inputs=inputs, outputs=outputs)<br />
model.compile(loss=my_mse_loss_b(B), optimizer=Adam(lr=0.0005))<br />
history = model.fit(x_train, y_train, batch_size=64, epochs=2)</p>
<p>The shape of my x_train is (1000,200,1),  y_train is (1000,200), B is (1000,)<br />
When x_train[0] and  y_train[0] pass to the training model, B[0] is passed as b, then x_train[1] and  y_train[1] pass to the trainingmodel, B[1] is passed as b<br />
Is that possible?<br />
Would you please give me a hint?<br />
Thanks, have a nice day!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David Signh		</title>
		<link>https://petaminds.com/advanced-keras-custom-loss-functions/#comment-18</link>

		<dc:creator><![CDATA[David Signh]]></dc:creator>
		<pubDate>Thu, 07 Nov 2019 20:28:10 +0000</pubDate>
		<guid isPermaLink="false">https://petaminds.com/?p=1391#comment-18</guid>

					<description><![CDATA[That is what I am looking for.  Really struggling with this. Thanks for sharing.]]></description>
			<content:encoded><![CDATA[<p>That is what I am looking for.  Really struggling with this. Thanks for sharing.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: tungnd		</title>
		<link>https://petaminds.com/advanced-keras-custom-loss-functions/#comment-17</link>

		<dc:creator><![CDATA[tungnd]]></dc:creator>
		<pubDate>Thu, 24 Oct 2019 06:23:29 +0000</pubDate>
		<guid isPermaLink="false">https://petaminds.com/?p=1391#comment-17</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://petaminds.com/advanced-keras-custom-loss-functions/#comment-16&quot;&gt;Anonymous&lt;/a&gt;.

You are welcome! :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://petaminds.com/advanced-keras-custom-loss-functions/#comment-16">Anonymous</a>.</p>
<p>You are welcome! 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anonymous		</title>
		<link>https://petaminds.com/advanced-keras-custom-loss-functions/#comment-16</link>

		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Thu, 24 Oct 2019 03:40:05 +0000</pubDate>
		<guid isPermaLink="false">https://petaminds.com/?p=1391#comment-16</guid>

					<description><![CDATA[Thank you a Tung! Super good sharing!]]></description>
			<content:encoded><![CDATA[<p>Thank you a Tung! Super good sharing!</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
