# \#loss-function

**URL:** https://discourse.julialang.org/tag/loss-function/1737.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Why is the loss function increasing when fitting a line?](https://discourse.julialang.org/t/why-is-the-loss-function-increasing-when-fitting-a-line/130600)

<div class="topic-metadata">

**Author:** [@\_jovian](https://discourse.julialang.org/u/_jovian)\
**Replies:** 2\
**Last updated:** [July 10, 2025, 1:37pm UTC](https://discourse.julialang.org/t/why-is-the-loss-function-increasing-when-fitting-a-line/130600 "2025-07-10T13:37:12Z")

</div>

Hello everyone, I’m following the “Fitting a Line” from the Flux.jl guide. It works as expected with the given data, as well as when modifying the predicted function (e.g. actual(x) = 3x - 1). I was trying to change th…

---

## [Custom loss functions in \`Lux.jl\`](https://discourse.julialang.org/t/custom-loss-functions-in-lux-jl/125661)

<div class="topic-metadata">

**Author:** [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Replies:** 5\
**Last updated:** [February 10, 2025, 4:28pm UTC](https://discourse.julialang.org/t/custom-loss-functions-in-lux-jl/125661 "2025-02-10T16:28:29Z")

</div>

I am currently getting accustomed to the Lux.jl package. I want to use a custom loss function which includes a l\_2-regression term consisting of the model weights. I defined my custom loss function as function loss\_func…
