| Conditions | 1 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | """This script provides an example of using custom backbone for training.""" |
||
| 30 | def call(self, y_true: tf.Tensor, y_pred: tf.Tensor) -> tf.Tensor: |
||
| 31 | """ |
||
| 32 | Return loss for a batch. |
||
| 33 | |||
| 34 | :param y_true: shape = (batch, ...) |
||
| 35 | :param y_pred: shape = (batch, ...) |
||
| 36 | :return: shape = (batch,) |
||
| 37 | """ |
||
| 38 | loss = tf.math.squared_difference(y_true, y_pred) |
||
| 39 | loss = self.flatten(loss) |
||
| 40 | loss = tf.reduce_mean(loss, axis=1) |
||
| 41 | loss = tf.math.sqrt(loss) |
||
| 42 | return loss |
||
| 43 | |||
| 52 |