Skip to content

Commit 0636977

Browse files
committed
better printing
1 parent 55869a1 commit 0636977

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/Architecture/ActivationFunction.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ struct Id <: ActivationFunction end
1818

1919
(::Id)(x) = x
2020

21+
Base.show(io::IO, ::Id) = print(io, Id)
22+
2123
"""
2224
ReLU
2325
@@ -31,6 +33,8 @@ struct ReLU <: ActivationFunction end
3133

3234
(::ReLU)(x) = max.(x, zero(eltype(x)))
3335

36+
Base.show(io::IO, ::ReLU) = print(io, ReLU)
37+
3438
"""
3539
Sigmoid
3640
@@ -44,6 +48,8 @@ struct Sigmoid <: ActivationFunction end
4448

4549
(::Sigmoid)(x) = @. 1 / (1 + exp(-x))
4650

51+
Base.show(io::IO, ::Sigmoid) = print(io, Sigmoid)
52+
4753
"""
4854
Tanh
4955
@@ -57,6 +63,8 @@ struct Tanh <: ActivationFunction end
5763

5864
(::Tanh)(x) = tanh.(x)
5965

66+
Base.show(io::IO, ::Tanh) = print(io, Tanh)
67+
6068
"""
6169
LeakyReLU{N<:Number}
6270
@@ -78,6 +86,8 @@ end
7886
(lr::LeakyReLU)(x::Number) = x >= zero(x) ? x : lr.slope * x
7987
(lr::LeakyReLU)(x::AbstractVector) = lr.(x)
8088

89+
Base.show(io::IO, lr::LeakyReLU) = print(io, "$LeakyReLU($(lr.slope))")
90+
8191
# constant instances of each activation function
8292
const _id = Id()
8393
const _relu = ReLU()

src/Architecture/DenseLayerOp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function Base.:isapprox(L1::DenseLayerOp, L2::DenseLayerOp; atol::Real=0,
6464
end
6565

6666
function Base.show(io::IO, L::DenseLayerOp)
67-
str = "$(string(DenseLayerOp)) with $(dim_in(L)) inputs, $(dim_out(L)) " *
67+
str = "$DenseLayerOp with $(dim_in(L)) inputs, $(dim_out(L)) " *
6868
"outputs, and $(L.activation) activation"
6969
return print(io, str)
7070
end

src/Architecture/FeedforwardNetwork.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function load_Flux_convert_network()
5757
end
5858

5959
function Base.show(io::IO, N::FeedforwardNetwork)
60-
str = "$(string(FeedforwardNetwork)) with $(dim_in(N)) inputs, " *
60+
str = "$FeedforwardNetwork with $(dim_in(N)) inputs, " *
6161
"$(dim_out(N)) outputs, and $(length(N)) layers:"
6262
for l in layers(N)
6363
str *= "\n- $l"

0 commit comments

Comments
 (0)