# Machine Learning

**URL:** https://discourse.julialang.org/c/domain/ml/24.md?page=15

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

**Page:** 16

---

## [Sobolov training in Flux - first derivative of input wrt output in loss function](https://discourse.julialang.org/t/sobolov-training-in-flux-first-derivative-of-input-wrt-output-in-loss-function/99612)

<div class="topic-metadata">

**Author:** [@Santa1806](https://discourse.julialang.org/u/Santa1806)\
**Replies:** 0\
**Last updated:** [May 30, 2023, 3:19pm UTC](https://discourse.julialang.org/t/sobolov-training-in-flux-first-derivative-of-input-wrt-output-in-loss-function/99612 "2023-05-30T15:19:28Z")

</div>

I have a dataset with input images x\_train, an objective value corresponding to each image y\_train, and the set of derivatives of y\_train wrt x\_train, dc\_train. I would like to train a CNN using this data, where I find t…

---

## [What is the underlying logic of Adding an Environment Wrapper in ReinforcementLearning.jl?](https://discourse.julialang.org/t/what-is-the-underlying-logic-of-adding-an-environment-wrapper-in-reinforcementlearning-jl/99539)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 1\
**Last updated:** [May 29, 2023, 7:25am UTC](https://discourse.julialang.org/t/what-is-the-underlying-logic-of-adding-an-environment-wrapper-in-reinforcementlearning-jl/99539 "2023-05-29T07:25:44Z")

</div>

When customizing an environment using ReinforcementLearning.jl, we need to transform the environment using some environment wrappers because a TabularQApproximator only accepts states of type Int, as the example code sho…

---

## [Flux: 1D convolutions (on genomic data)](https://discourse.julialang.org/t/flux-1d-convolutions-on-genomic-data/74874)

<div class="topic-metadata">

**Author:** [@wc4wc4wc4](https://discourse.julialang.org/u/wc4wc4wc4)\
**Replies:** 20\
**Last updated:** [May 28, 2023, 7:27pm UTC](https://discourse.julialang.org/t/flux-1d-convolutions-on-genomic-data/74874 "2023-05-28T19:27:08Z")

</div>

I am trying to recreate this tutorial from Python. This basically deals with how to apply deep learning to genomic data. As such, the input consists of sequences, where each sequence is based on a combination of any of …

---

## [Mutable objects in Enzyme.jl](https://discourse.julialang.org/t/mutable-objects-in-enzyme-jl/99433)

<div class="topic-metadata">

**Author:** [@Iris\_Allevi](https://discourse.julialang.org/u/Iris_Allevi)\
**Replies:** 7\
**Last updated:** [May 28, 2023, 5:32pm UTC](https://discourse.julialang.org/t/mutable-objects-in-enzyme-jl/99433 "2023-05-28T17:32:51Z")

</div>

Hi everyone I am new to automatic differentiation. I decided to use Enzyme since I need to handle mutating objects (even if I am not differentiating with respect to these objects). I try to write a minimal, self-consis…

---

## [Strange gradient behavior related to function applications](https://discourse.julialang.org/t/strange-gradient-behavior-related-to-function-applications/99508)

<div class="topic-metadata">

**Author:** [@wormholestds9](https://discourse.julialang.org/u/wormholestds9)\
**Replies:** 0\
**Last updated:** [May 28, 2023, 8:36am UTC](https://discourse.julialang.org/t/strange-gradient-behavior-related-to-function-applications/99508 "2023-05-28T08:36:56Z")

</div>

I ran into a baffling problem. I am using a sparse matrix sm as a weight matrix for a Dense unit. It is 2000x2000 sparse matrix with 100000 non-zero Float32 entries I created two Dense units: b = zeros(Float32,200…

---

## [Direct Feedback Alignment](https://discourse.julialang.org/t/direct-feedback-alignment/99414)

<div class="topic-metadata">

**Author:** [@marco\_menarini](https://discourse.julialang.org/u/marco_menarini)\
**Replies:** 0\
**Last updated:** [May 25, 2023, 11:03pm UTC](https://discourse.julialang.org/t/direct-feedback-alignment/99414 "2023-05-25T23:03:45Z")

</div>

I am trying to implement a form of Direct Feedback Aligment that allows for custom derivatives based on this paper using Flux The code seems to work correctly and fast if I pass the data points individually, but it beco…

---

## [Incorporating SVD factorization into GPUs with CUDA](https://discourse.julialang.org/t/incorporating-svd-factorization-into-gpus-with-cuda/99252)

<div class="topic-metadata">

**Author:** [@jarroyoe](https://discourse.julialang.org/u/jarroyoe)\
**Replies:** 7\
**Last updated:** [May 23, 2023, 2:31am UTC](https://discourse.julialang.org/t/incorporating-svd-factorization-into-gpus-with-cuda/99252 "2023-05-23T02:31:21Z")

</div>

I’m trying to run the following code to optimize the spectral radius of the weight matrices of a neural network: using CUDA, Random, Lux, ComponentArrays, Optimization, OptimizationOptimisers, OptimizationOptimJL, Linea…

---

## [ReverseDiff over ForwardDiff behaves strangely with Lux networks (Issue)](https://discourse.julialang.org/t/reversediff-over-forwarddiff-behaves-strangely-with-lux-networks-issue/99175)

<div class="topic-metadata">

**Author:** [@Bizzi](https://discourse.julialang.org/u/Bizzi)\
**Replies:** 3\
**Last updated:** [May 23, 2023, 2:06am UTC](https://discourse.julialang.org/t/reversediff-over-forwarddiff-behaves-strangely-with-lux-networks-issue/99175 "2023-05-23T02:06:13Z")

</div>

Hello everyone. For my work with PINNs, I am trying to use ReverseDiff to calculate the gradient of a loss function that itself contains a ForwardDiff gradient. It is easy enough to do so with explicitly-parametrized dec…

---

## [Radial basis functions in surrogates.jl?](https://discourse.julialang.org/t/radial-basis-functions-in-surrogates-jl/99144)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 4\
**Last updated:** [May 21, 2023, 9:47pm UTC](https://discourse.julialang.org/t/radial-basis-functions-in-surrogates-jl/99144 "2023-05-21T21:47:54Z")

</div>

Hi, I’m trying to understand what RBFs Surrogates.jl is using. For example, the documentation only specifies that it uses RadialBasis . The \[code\] specifies that there is a linearRadial and cubicRadial. What equation is…

---

## [Julia supported by LangChain?](https://discourse.julialang.org/t/julia-supported-by-langchain/98509)

<div class="topic-metadata">

**Author:** [@Alex\_Tantos](https://discourse.julialang.org/u/Alex_Tantos)\
**Replies:** 14\
**Last updated:** [May 21, 2023, 5:27pm UTC](https://discourse.julialang.org/t/julia-supported-by-langchain/98509 "2023-05-21T17:27:21Z")

</div>

Hi there! Is anyone aware of any attempts/plans by LangChain to support julia? Any answer will be greatly appreciated! Best! Alex

---

## [Calculating Hessians of loss w.r.t parameters of a system of ODEs](https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025)

<div class="topic-metadata">

**Author:** [@KK\_JuliaNoob](https://discourse.julialang.org/u/KK_JuliaNoob)\
**Replies:** 1\
**Last updated:** [May 18, 2023, 12:30am UTC](https://discourse.julialang.org/t/calculating-hessians-of-loss-w-r-t-parameters-of-a-system-of-odes/99025 "2023-05-18T00:30:09Z")

</div>

I have a system of ~10 ODEs with ~20 parameters and a loss function (e.g. MSE) that is evaluated on the trace of the ODE solution. What’s an efficient way to calculate the Hessian matrix of the loss w.r.t the parameters?…

---

## [How do I specify a precomputed kernel in SVM using LIBSVM or MLJ?](https://discourse.julialang.org/t/how-do-i-specify-a-precomputed-kernel-in-svm-using-libsvm-or-mlj/61962)

<div class="topic-metadata">

**Author:** [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Replies:** 4\
**Last updated:** [May 17, 2023, 8:01pm UTC](https://discourse.julialang.org/t/how-do-i-specify-a-precomputed-kernel-in-svm-using-libsvm-or-mlj/61962 "2023-05-17T20:01:25Z")

</div>

Question arising in an MLJ slack post: maybe this is a naive question, but how do you actually train an SVM using a precomputed kernel using LIBSVM or MLJ? I can’t seem to find a way to “give” the kernel matrix to any s…

---

## [Problem loading saved neural network](https://discourse.julialang.org/t/problem-loading-saved-neural-network/98882)

<div class="topic-metadata">

**Author:** [@LucasMSpereira](https://discourse.julialang.org/u/LucasMSpereira)\
**Replies:** 9\
**Last updated:** [May 16, 2023, 4:09pm UTC](https://discourse.julialang.org/t/problem-loading-saved-neural-network/98882 "2023-05-16T16:09:46Z")

</div>

When trying to load a saved Flux NN with BSON.@load datasetPath \* "trainedNetworks/convnextGen.bson" cpuGenerator I’m getting a invalid struct allocation error. Since doing this last time, the only thing I did was upd…

---

## [Solve a DSGE model using neural networks](https://discourse.julialang.org/t/solve-a-dsge-model-using-neural-networks/98873)

<div class="topic-metadata">

**Author:** [@Vahagn](https://discourse.julialang.org/u/Vahagn)\
**Replies:** 0\
**Last updated:** [May 15, 2023, 10:32am UTC](https://discourse.julialang.org/t/solve-a-dsge-model-using-neural-networks/98873 "2023-05-15T10:32:37Z")

</div>

Hi, I have a DSGE model for which I need to approximate decision functions using neural network. I have already written many parts of my code. But I don’t know how to train it. I have written some training loop in the b…

---

## [Flux output layer with custom activation function](https://discourse.julialang.org/t/flux-output-layer-with-custom-activation-function/98821)

<div class="topic-metadata">

**Author:** [@YuriS](https://discourse.julialang.org/u/YuriS)\
**Replies:** 2\
**Last updated:** [May 14, 2023, 2:31pm UTC](https://discourse.julialang.org/t/flux-output-layer-with-custom-activation-function/98821 "2023-05-14T14:31:35Z")

</div>

Hello! I am trying to create a neural network that is mostly standard, except with an output layer that applies a sigmoid activation function to one of its four outputs, and just identity to the other three outputs. I …

---

## [Flux Dense Layer Type Instability](https://discourse.julialang.org/t/flux-dense-layer-type-instability/98642)

<div class="topic-metadata">

**Author:** [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Replies:** 7\
**Last updated:** [May 11, 2023, 4:20pm UTC](https://discourse.julialang.org/t/flux-dense-layer-type-instability/98642 "2023-05-11T16:20:12Z")

</div>

Hi. I am stumped as to why the forward pass is type unstable. It’s effectively a varying length chain similar to Flux.Chain on an alternating sequence of dense and dropout layers: struct MLP dense::Vector{Flux.Dense…

---

## [Neural network training for DSGE model](https://discourse.julialang.org/t/neural-network-training-for-dsge-model/98567)

<div class="topic-metadata">

**Author:** [@Vahagn](https://discourse.julialang.org/u/Vahagn)\
**Replies:** 0\
**Last updated:** [May 9, 2023, 5:55pm UTC](https://discourse.julialang.org/t/neural-network-training-for-dsge-model/98567 "2023-05-09T17:55:11Z")

</div>

Hi, I have a DSGE model for which I need to approximate decision functions using neural network. I have already written many parts of my code. But I don’t know how to train it. I have written some training loop in the b…

---

## [Zygote Update with Parametric Type](https://discourse.julialang.org/t/zygote-update-with-parametric-type/98588)

<div class="topic-metadata">

**Author:** [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Replies:** 5\
**Last updated:** [May 10, 2023, 6:26am UTC](https://discourse.julialang.org/t/zygote-update-with-parametric-type/98588 "2023-05-10T06:26:22Z")

</div>

Hi. I’m trying to update my flux model which is parameterized by two types: abstract type C end struct A \<: C end struct B \<: C end struct Block{T\<:C} C\_inout::Int time::Vector{Float64} end Flux.@functor Block…

---

## [Loss/Accuracy computation in validation set in Flux](https://discourse.julialang.org/t/loss-accuracy-computation-in-validation-set-in-flux/98590)

<div class="topic-metadata">

**Author:** [@imantha](https://discourse.julialang.org/u/imantha)\
**Replies:** 1\
**Last updated:** [May 10, 2023, 5:05am UTC](https://discourse.julialang.org/t/loss-accuracy-computation-in-validation-set-in-flux/98590 "2023-05-10T05:05:24Z")

</div>

Hi I have written the code below following the examples in Flux model zoo (conv\_mnist). I have a feeling I am doing something wrong especially in the validation set. I have some experience with pytorch and usually when y…

---

## [Zygote adjoints for cholesky factorization on sparse arrays](https://discourse.julialang.org/t/zygote-adjoints-for-cholesky-factorization-on-sparse-arrays/98578)

<div class="topic-metadata">

**Author:** [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Replies:** 0\
**Last updated:** [May 9, 2023, 9:53pm UTC](https://discourse.julialang.org/t/zygote-adjoints-for-cholesky-factorization-on-sparse-arrays/98578 "2023-05-09T21:53:30Z")

</div>

Hi. Is there a quick and dirty way of getting AD to work when dealing with cholesky factorizations? The example below performs factorization (must be done inside) followed by solving a system of equations. The goal is t…

---

## [Writing a neural network training code with ADAM optimizer](https://discourse.julialang.org/t/writing-a-neural-network-training-code-with-adam-optimizer/98472)

<div class="topic-metadata">

**Author:** [@Vahagn](https://discourse.julialang.org/u/Vahagn)\
**Replies:** 1\
**Last updated:** [May 8, 2023, 2:00pm UTC](https://discourse.julialang.org/t/writing-a-neural-network-training-code-with-adam-optimizer/98472 "2023-05-08T14:00:20Z")

</div>

I have a code for my DSGE model and I want to find decision functions using neural networks, namely using deep learning with ADAM optimizer. I read the quick start example in Flux, but I, unfortunately, I don’t know how …

---

## [Julia response to Auto-GPT](https://discourse.julialang.org/t/julia-response-to-auto-gpt/98229)

<div class="topic-metadata">

**Author:** [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Replies:** 2\
**Last updated:** [May 6, 2023, 7:44pm UTC](https://discourse.julialang.org/t/julia-response-to-auto-gpt/98229 "2023-05-06T19:44:28Z")

</div>

Now that we have a wrapper for the openAI API it would be pretty cool to have an Auto-GPT like package that the julia community could contribute to. It’s pretty amazing how simply having the LLM talk to itself(s) can gre…

---

## [Using NeuralPDE for prediction?](https://discourse.julialang.org/t/using-neuralpde-for-prediction/98359)

<div class="topic-metadata">

**Author:** [@vineetjnair9](https://discourse.julialang.org/u/vineetjnair9)\
**Replies:** 2\
**Last updated:** [May 6, 2023, 4:01am UTC](https://discourse.julialang.org/t/using-neuralpde-for-prediction/98359 "2023-05-06T04:01:47Z")

</div>

Hi, I’m pretty new to Julia ML and I’m trying to use NeuralPDE.jl to solve a system of ODEs. I’m following this tutorial and am able to get a pretty good fit close to the true solution. But is there a way I can use the p…

---

## [Chaining Custom Layers using Custom Signature](https://discourse.julialang.org/t/chaining-custom-layers-using-custom-signature/98357)

<div class="topic-metadata">

**Author:** [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Replies:** 1\
**Last updated:** [May 5, 2023, 6:01am UTC](https://discourse.julialang.org/t/chaining-custom-layers-using-custom-signature/98357 "2023-05-05T06:01:37Z")

</div>

Hi. Is there an idiomatic way of chaining layers in Flux when not all of the outputs of the previous layer pipe into the next layer. Unlike Flux.Chain which directly pipes all of the data, how can one create a custom lay…

---

## [Predicting a Successful Mt Everest Climb with Julia](https://discourse.julialang.org/t/predicting-a-successful-mt-everest-climb-with-julia/98341)

<div class="topic-metadata">

**Author:** [@dm13450](https://discourse.julialang.org/u/dm13450)\
**Replies:** 1\
**Last updated:** [May 4, 2023, 8:24pm UTC](https://discourse.julialang.org/t/predicting-a-successful-mt-everest-climb-with-julia/98341 "2023-05-04T20:24:01Z")

</div>

I’ve written about using MLJ.jl and the Himalayan Database to try and predict a successful Mt Everest climb. Check it out here: Predicting a Successful Mt Everest Climb | Dean Markwick

---

## [How to best parallelize custom decision tree / forest?](https://discourse.julialang.org/t/how-to-best-parallelize-custom-decision-tree-forest/98328)

<div class="topic-metadata">

**Author:** [@MiquellaXMalenia](https://discourse.julialang.org/u/MiquellaXMalenia)\
**Replies:** 0\
**Last updated:** [May 4, 2023, 3:39pm UTC](https://discourse.julialang.org/t/how-to-best-parallelize-custom-decision-tree-forest/98328 "2023-05-04T15:39:45Z")

</div>

Hello, Could anyone give me advice on the best way to parallelize a custom decision tree or forest algorithm on CPU / GPU? I am currently building my own from scratch to experiment with some of my ideas for multi-class…

---

## [Average of Zygote gradients](https://discourse.julialang.org/t/average-of-zygote-gradients/98303)

<div class="topic-metadata">

**Author:** [@RoBertimus](https://discourse.julialang.org/u/RoBertimus)\
**Replies:** 2\
**Last updated:** [May 4, 2023, 12:11pm UTC](https://discourse.julialang.org/t/average-of-zygote-gradients/98303 "2023-05-04T12:11:42Z")

</div>

Hi Everyone, I would like to know how I can manually calculate for example the mean over an array of gradients of a neural network. I have the following setup : In the training loop I calculate the gradient of the los…

---

## [Zygote gradient slow for TriMAP](https://discourse.julialang.org/t/zygote-gradient-slow-for-trimap/98235)

<div class="topic-metadata">

**Author:** [@somethrowawaynamegoo](https://discourse.julialang.org/u/somethrowawaynamegoo)\
**Replies:** 0\
**Last updated:** [May 3, 2023, 7:06am UTC](https://discourse.julialang.org/t/zygote-gradient-slow-for-trimap/98235 "2023-05-03T07:06:38Z")

</div>

Hello, I was trying to implement TriMAP using Zygote’s gradient function, but it is very slow and the data is very high dimensional, is there any tip to improve the performance of the gradient function? The following fu…

---

## [Request to upgrade to LossFunctions.jl](https://discourse.julialang.org/t/request-to-upgrade-to-lossfunctions-jl/97738)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 36\
**Last updated:** [May 3, 2023, 5:21pm UTC](https://discourse.julialang.org/t/request-to-upgrade-to-lossfunctions-jl/97738 "2023-05-03T17:21:55Z")

</div>

Dear ML community, we released LossFunctions.jl v0.9 with a few important breaking changes: Reversed order of arguments to match other ecosystems, loss(yhat, y) is now the order. Removed the ObsDim business to support …

---

## [What to do about models not loading in Flux? Critical breakage](https://discourse.julialang.org/t/what-to-do-about-models-not-loading-in-flux-critical-breakage/97881)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 3\
**Last updated:** [May 3, 2023, 4:48pm UTC](https://discourse.julialang.org/t/what-to-do-about-models-not-loading-in-flux-critical-breakage/97881 "2023-05-03T16:48:26Z")

</div>

I use Flux to make ML models as part of my graduate studies. I read some time ago that you couldn’t trust model’s saved in bson-format, so I made a solution where I would recreate the model by dynamic loading (facing eno…

[Previous page](https://discourse.julialang.org/c/domain/ml/24.md?page=14)

[Next page](https://discourse.julialang.org/c/domain/ml/24.md?page=16)
