# TypeError: non-boolean (Missing) used in boolean context when collecting parameters

**URL:** <https://discourse.julialang.org/t/typeerror-non-boolean-missing-used-in-boolean-context-when-collecting-parameters/20593>\
**Category:** New to Julia\
**Tags:** question, package, flux\
**Created:** [February 8, 2019, 7:55pm UTC](https://discourse.julialang.org/t/typeerror-non-boolean-missing-used-in-boolean-context-when-collecting-parameters/20593 "2019-02-08T19:55:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [February 8, 2019, 7:55pm UTC](https://discourse.julialang.org/t/typeerror-non-boolean-missing-used-in-boolean-context-when-collecting-parameters/20593/1 "2019-02-08T19:55:13Z")

</div>

I have a problem happening in Flux that I cannot explain. When I run the MVE defined below an error happens. The error is given below the code.

```julia
using Flux
using Flux.Tracker

struct AffineB{F, S, T}
    W::S
    b::T

    μ::T
    logσ::T

    φ::F
end

z(μ, logσ) = μ + exp(logσ)*randn()

function initaffineb(in::Integer, out::Integer, μ, logσ)
    s = z.(μ, logσ)
    W, b = reshape(s[1:out*in], out, in), reshape(s[out*in+1:end], out)
    W, b
end

function initaffineb(in::Integer, out::Integer)
    μ, logσ = param(zeros(out*in+out)), param(zeros(out*in+out))
    W, b = initaffineb(in, out, μ, logσ)
    W, b, μ, logσ
end

function AffineB(in::Integer, out::Integer)
    W, b, μ, logσ = initaffineb(in, out)
    AffineB(W, b, μ, logσ, identity)
end

function AffineB(in::Integer, out::Integer, φ::Function)
    W, b, μ, logσ = initaffineb(in, out)
    AffineB(W, b, μ, logσ, φ)
end

function (a::AffineB)(X::AbstractArray)
    W, b, φ = a.W, a.b, a.φ
    φ.(W*X .+ b)
end

Flux.@treelike AffineB # This should allow me to call params on an AffineB type.

# Simple OR logic problem
x = [0 0 1 1; 0 1 0 1]
y = [0 1 1 1]
a = AffineB(2, 1)

l = sum((a(x) .- y).^2) # Sum squared error
Tracker.back!(l) # Backpropagate
pars = params(a) # Collect all parameters where it dies...

```

```julia
ERROR: TypeError: non-boolean (Missing) used in boolean context
Stacktrace:
 [1] ==(::Flux.Tracker.Call{Missing,Tuple{}}, ::Flux.Tracker.Call{Nothing,Tuple{}}) at /home/michael/.julia/packages/Flux/8XpDt/src/tracker/Tracker.jl:28
 [2] isleaf(::Flux.Tracker.Tracked{Array{Float64,2}}) at /home/michael/.julia/packages/Flux/8XpDt/src/tracker/Tracker.jl:43
 [3] isleaf at /home/michael/.julia/packages/Flux/8XpDt/src/tracker/Tracker.jl:14 [inlined]
 [4] (::getfield(Flux, Symbol("##43#45")){Params})(::TrackedArray{…,Array{Float64,2}}) at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:39
 [5] #prefor#40 at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:32 [inlined]
 [6] #prefor at ./none:0 [inlined]
 [7] (::getfield(Flux, Symbol("##41#42")){Flux.Tracker.IdSet{Any},getfield(Flux, Symbol("##43#45")){Params}})(::TrackedArray{…,Array{Float64,2}}) at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:33
 [8] foreach(::getfield(Flux, Symbol("##41#42")){Flux.Tracker.IdSet{Any},getfield(Flux, Symbol("##43#45")){Params}}, ::Tuple{TrackedArray{…,Array{Float64,2}},TrackedArray{…,Array{Float64,1}},TrackedArray{…,Array{Float64,1}},TrackedArray{…,Array{Float64,1}},typeof(identity)}) at ./abstractarray.jl:1866
 [9] #prefor#40 at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:33 [inlined]
 [10] prefor at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:31 [inlined]
 [11] params(::AffineB{typeof(identity),TrackedArray{…,Array{Float64,2}},TrackedArray{…,Array{Float64,1}}}) at /home/michael/.julia/packages/Flux/8XpDt/src/treelike.jl:39
 [12] top-level scope at none:0

```

I’m running Flux 0.7.3 and

> Julia Version 1.1.0  
> Commit 80516ca202 (2019-01-21 21:24 UTC)  
> Platform Info:  
> OS: Linux (x86\_64-pc-linux-gnu)  
> CPU: Intel(R) Core™ i7-6650U CPU @ 2.20GHz  
> WORD\_SIZE: 64  
> LIBM: libopenlibm  
> LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

Any ideas?
