From 170dbe0ff3b10a0008fb7f09d02985c64046a154 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 9 Oct 2023 16:15:01 +0200 Subject: [PATCH] Added requested PR changes --- src/utils/parameter.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/parameter.jl b/src/utils/parameter.jl index 8955ce8e..14fe0f1d 100644 --- a/src/utils/parameter.jl +++ b/src/utils/parameter.jl @@ -46,7 +46,7 @@ length(x::Parameter) = length(x.data) or - clear_grad!(P::AbstractAbstractVector{<:Parameter}) + clear_grad!(P::AbstractVector{<:Parameter}) Set gradients of each `Parameter` in the network layer to `nothing`. """ @@ -94,16 +94,16 @@ end dot(p1::Parameter, p2::Parameter) = dot(p1.data, p2.data) norm(p::Parameter) = norm(p.data) +(p1::Parameter, p2::Parameter) = Parameter(p1.data+p2.data) -+(p1::Parameter, p2::T) where {T<:Real} = Parameter(p1.data+p2) -+(p1::T, p2::Parameter) where {T<:Real} = p2+p1 ++(p1::Parameter, p2::T) where {T<:Number} = Parameter(p1.data+p2) ++(p1::T, p2::Parameter) where {T<:Number} = p2+p1 -(p1::Parameter, p2::Parameter) = Parameter(p1.data-p2.data) --(p1::Parameter, p2::T) where {T<:Real} = Parameter(p1.data-p2) --(p1::T, p2::Parameter) where {T<:Real} = -(p2-p1) +-(p1::Parameter, p2::T) where {T<:Number} = Parameter(p1.data-p2) +-(p1::T, p2::Parameter) where {T<:Number} = -(p2-p1) -(p::Parameter) = Parameter(-p.data) -*(p1::Parameter, p2::T) where {T<:Real} = Parameter(p1.data*p2) -*(p1::T, p2::Parameter) where {T<:Real} = p2*p1 -/(p1::Parameter, p2::T) where {T<:Real} = Parameter(p1.data/p2) -/(p1::T, p2::Parameter) where {T<:Real} = Parameter(p1/p2.data) +*(p1::Parameter, p2::T) where {T<:Number} = Parameter(p1.data*p2) +*(p1::T, p2::Parameter) where {T<:Number} = p2*p1 +/(p1::Parameter, p2::T) where {T<:Number} = Parameter(p1.data/p2) +/(p1::T, p2::Parameter) where {T<:Number} = Parameter(p1/p2.data) # Shape manipulation