Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipVinc committed Apr 25, 2021
1 parent c69f7e6 commit 6674421
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Loggers/LogHParams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ end

DiscreteDomainElem = Union{String, Float64, Bool}

hparams_datatype_sym(::Type{String}) = :DATA_TYPE_STRING
hparams_datatype_sym(::Type{<:AbstractString}) = :DATA_TYPE_STRING
hparams_datatype_sym(::Type{Float64}) = :DATA_TYPE_FLOAT64
hparams_datatype_sym(::Type{Bool}) = :DATA_TYPE_BOOL

function hparams_datatype(domain::DiscreteDomain{T}) where T <: DiscreteDomainElem
tensorboard.hparams._DataType[hparams_datatype_sym(T)]
end

ProtoBuf.google.protobuf.Value(x::Number) = Value(number_value=x)
ProtoBuf.google.protobuf.Value(x::Bool) = Value(bool_value=x)
ProtoBuf.google.protobuf.Value(x::AbstractString) = Value(string_value=x)
function ProtoBuf.google.protobuf.Value(x)
# custom constructors for ProtoBuf.google.protobuf.Value
function _Protobuf_Value(x)
@warn "Cannot create a ProtoBuf.google.protobuf.Value of type $(typeof(x)), defaulting to null."
Value(null_value=Int32(0))
end
_Protobuf_Value(x::Bool) = Value(bool_value=x)
_Protobuf_Value(x::Number) = Value(number_value=x)
_Protobuf_Value(x::AbstractString) = Value(string_value=x)


function ProtoBuf.google.protobuf.ListValue(domain::DiscreteDomain{T}) where T <: DiscreteDomainElem
function _Protobuf_ListValue(domain::DiscreteDomain{T})where T <: DiscreteDomainElem
ProtoBuf.google.protobuf.ListValue(
values = ProtoBuf.google.protobuf.Value.(domain.values)
)
Expand Down Expand Up @@ -58,7 +58,7 @@ function HParamInfo(hparam::HParam)
else
@assert isa(domain, DiscreteDomain)
(_type = hparams_datatype(domain),
domain_discrete = ProtoBuf.google.protobuf.ListValue(domain))
domain_discrete = _Protobuf_ListValue(domain))
end
HParamInfo(;name = hparam.name,
description = hparam.description,
Expand Down Expand Up @@ -177,7 +177,7 @@ function hparams_summary(hparams_dict::Dict{HParam, Any},
group_name = group_name,
start_time_secs = start_time_secs,
hparams = Dict(
hparam.name => ProtoBuf.google.protobuf.Value(val)
hparam.name => _ProtoBuf_Value(val)
for (hparam, val) hparams_dict
)
)
Expand Down

0 comments on commit 6674421

Please sign in to comment.