Skip to content

Instantly share code, notes, and snippets.

@Roger-luo
Created March 15, 2020 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roger-luo/17eec29fe45a09162542414fb186e68d to your computer and use it in GitHub Desktop.
Save Roger-luo/17eec29fe45a09162542414fb186e68d to your computer and use it in GitHub Desktop.
using Flux
struct Linear{T, WT <: AbstractMatrix{T}, BT <: AbstractVector{T}}
W::WT
b::BT
end
Flux.functor(m::Linear) = (m.W, m.b), (W, b) -> Linear(W, b)
m = Linear(rand(2, 2), rand(2))
params(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment