JuliaPy / JuliaPy/pyjulia

Error when trying to use Flux

Open
#491 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
893
Forks
101
PR merge metrics
No merged PRs in 30d

Description

I'm trying to reproduce basic example in https://fluxml.ai/Flux.jl/stable/models/overview/ using the pyjulia, computing the loss goes fine, but during the training it crashes:
```python
import julia
julia.install()
from julia import Julia
Julia(compiled_modules=False)
from julia import Flux
def actual(x): return 4*x + 2
x_train, x_test = [list(range(0,5))], [list(range(6,10))]
y_train, y_test = list(map(actual, x_train[0])), list(map(actual, x_test[0]))
model = Flux.Dense(1, 1)
model(x_train)
def loss(x, y): return Flux.Losses.mse(model(x), y)
loss(x_train, y_train)
parameters = Flux.params(model)
data = [(x_train, y_train)]
Flux.train_b(loss, parameters, data, Flux.ADAM())
```
everything runs as expected except of the last line:
```
RuntimeError:
```

how should I use Flux from python and define loss function in a differentiable way?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.