# Trying to train a variable GNN w/ GeometricFlux.jl

**URL:** https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246
**Category:** General Usage
**Tags:** question, package, flux
**Created:** [July 8, 2021, 12:04am UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246 "2021-07-08T00:04:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![eahenle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eahenle/32/19813_2.png) [@eahenle](https://discourse.julialang.org/u/eahenle)
#### Post date: [July 8, 2021, 12:04am UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246/1 "2021-07-08T00:04:48Z")

</div>

I am trying to train a gated graph neural network to predict molecular properties with `GeometricFlux.jl`: [GitHub - FluxML/GeometricFlux.jl: Geometric Deep Learning for Flux](https://github.com/FluxML/GeometricFlux.jl)

The inputs are `FeaturedGraph` objects of various morphologies. After quite a bit of trial-and-error, I have reached a point where the exception message is opaque to me and I do not know how to proceed. Code being used is here: [Trying to train a variable GNN w/ GeometricFlux.jl · GitHub](https://gist.github.com/eahenle/928db9620b652a4d4684633418b22c6b)

The error message is: `LoadError: MethodError: _pullback(::Zygote.Context, ::typeof(hcat)) is ambiguous.`

Can @yuehhua or anyone else suggest what is wrong?

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [July 8, 2021, 4:51am UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246/2 "2021-07-08T04:51:17Z")

</div>

You should provide more details. A minimum working example and in this case versions of your packages.

---

<div class="post-metadata">

### Author: ![eahenle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eahenle/32/19813_2.png) [@eahenle](https://discourse.julialang.org/u/eahenle)
#### Post date: [July 8, 2021, 5:16am UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246/3 "2021-07-08T05:16:38Z")

</div>

Julia 1.6.0  
Flux 0.12.1  
GeometricFlux 0.7.6  
GraphSignals 0.1.13  
LightGraphs 1.3.5  
MetaGraphs 0.6.7  
Zygote 0.6.13

Minimal code to reproduce idea and error:

```julia
using Flux, GeometricFlux, MetaGraphs

# convert a MetaGraph to FeaturedGraph
mg = MetaGraph()
add_vertices!(mg, 3)
add_edge!(mg, 1, 2)
add_edge!(mg, 2, 3)
adj_mat = adjacency_matrix(mg)
g = FeaturedGraph(adj_mat; nf=ones(2, nv(mg)))

# train the model
model = Chain(GatedGraphConv(2, 1, aggr=:mean), softmax)
loss(x, y) = Flux.mse(model(x), y)
@Flux.epochs 1 Flux.train!(
    loss, 
    Flux.params(model), 
    [(g, 1.0)], 
    ADAM()
)

```

---

<div class="post-metadata">

### Author: ![logankilpatrick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logankilpatrick/32/38123_2.png) [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)
#### Post date: [July 11, 2021, 12:39pm UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246/5 "2021-07-11T12:39:31Z")

</div>

The related Stack overflow question: [julia - Trying to train a variable GNN w/ GeometricFlux.jl - Stack Overflow](https://stackoverflow.com/questions/68294170/trying-to-train-a-variable-gnn-w-geometricflux-jl) I took a look at this but it’s beyond my understanding at the moment.

---

<div class="post-metadata">

### Author: ![yuehhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuehhua/32/12281_2.png) [@yuehhua](https://discourse.julialang.org/u/yuehhua)
#### Post date: [July 19, 2021, 1:23pm UTC](https://discourse.julialang.org/t/trying-to-train-a-variable-gnn-w-geometricflux-jl/64246/6 "2021-07-19T13:23:14Z")

</div>

Sorry for being late. Could you give the full error messages? It seems like the error occurs on AD for `hcat`.
