<p dir="auto">I am trying to make a loss function with varying input sizes. I am getting the following error:<br>
<code class="notranslate">TypeError: __int__ returned non-int (type NoneType)</code> when compiling the model</p>
<p dir="auto">Steps to get the error:<br>
Make architecture in Keras with None type as input: <code class="notranslate">input_image = Input(shape=(None, None, 3))</code><br>
Then make a custom loss function and try to access the size of the tensor</p>
<p dir="auto"><code class="notranslate">def custom_loss(y_true, y_pred):</code><br>
<code class="notranslate">yp_size = [int(y_pred.get_shape()[0]), int(y_pred.get_shape()[1]), int(y_pred.get_shape()[2]), int(y_pred.get_shape()[3])]</code><br>
<code class="notranslate">cell_x = tf.tile(tf.range(yp_size[1]), [yp_size[2]]) # And code will go on eventually returning loss</code></p>
<p dir="auto">Then compile model:<br>
<code class="notranslate">model.compile(loss=custom_loss, optimizer=optimizer)</code></p>
<p dir="auto">Theoretically the method should run fine at runtime but it is showing this error. Can I get any workaround for this?</p>
<p dir="auto">P.S. I don't want to pad my tensors to a fixed size. And sorry if the issue got uploaded multiple times.</p>
<p dir="auto">I am trying to make a loss function with varying input sizes. I am getting the following error:<br>
<code class="notranslate">TypeError: __int__ returned non-int (type NoneType)</code> when compiling the model</p>
<p dir="auto">Steps to get the error:<br>
Make architecture in Keras with None type as input: <code class="notranslate">input_image = Input(shape=(None, None, 3))</code><br>
Then make a custom loss function and try to access the size of the tensor</p>
<p dir="auto"><code class="notranslate">def custom_loss(y_true, y_pred):</code><br>
<code class="notranslate">yp_size = [int(y_pred.get_shape()[0]), int(y_pred.get_shape()[1]), int(y_pred.get_shape()[2]), int(y_pred.get_shape()[3])]</code><br>
<code class="notranslate">cell_x = tf.tile(tf.range(yp_size[1]), [yp_size[2]]) # And code will go on eventually returning loss</code></p>
<p dir="auto">Then compile model:<br>
<code class="notranslate">model.compile(loss=custom_loss, optimizer=optimizer)</code></p>
<p dir="auto">Theoretically the method should run fine at runtime but it is showing this error. Can I get any workaround for this?</p>
<p dir="auto">P.S. I don't want to pad my tensors to a fixed size</p>