@@ -37,7 +37,9 @@ test_hparams_log_dir = "test_hparams_logs/"
3737 end
3838end
3939
40- @testset " Serialise hparams" begin
40+ const hparams_metadata_encoded_bytes = UInt8[0x1a , 0x5b , 0x0a , 0x0e , 0x0a , 0x06 , 0x6d , 0x65 , 0x74 , 0x68 , 0x6f , 0x64 , 0x12 , 0x04 , 0x1a , 0x02 , 0x4d , 0x43 , 0x0a , 0x12 , 0x0a , 0x05 , 0x61 , 0x6c , 0x70 , 0x68 , 0x61 , 0x12 , 0x09 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xe0 , 0x3f , 0x0a , 0x0f , 0x0a , 0x02 , 0x69 , 0x64 , 0x12 , 0x09 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf0 , 0x3f , 0x0a , 0x13 , 0x0a , 0x0d , 0x6f , 0x70 , 0x74 , 0x69 , 0x6d , 0x69 , 0x73 , 0x61 , 0x74 , 0x69 , 0x6f , 0x6e , 0x73 , 0x12 , 0x02 , 0x20 , 0x00 , 0x0a , 0x0f , 0x0a , 0x02 , 0x70 , 0x31 , 0x12 , 0x09 , 0x11 , 0x9a , 0x99 , 0x99 , 0x99 , 0x99 , 0x99 , 0xb9 , 0x3f ]
41+
42+ @testset " Encoding hparams metadata" begin
4143 hparams_config = Dict {String, Any} (
4244 " id" => Float64 (1 ),
4345 " alpha" => 0.5 ,
6264
6365 session_start_info = TensorBoardLogger. HP. SessionStartInfo (hparams_dict, " " , " " , " " , zero (Float64))
6466 session_start_content = TensorBoardLogger. HP. HParamsPluginData (PLUGIN_DATA_VERSION, TensorBoardLogger. OneOf (:session_start_info , session_start_info))
65-
66- expected_bytes = UInt8[0x1a , 0x5b , 0x0a , 0x0e , 0x0a , 0x06 , 0x6d , 0x65 , 0x74 , 0x68 , 0x6f , 0x64 , 0x12 , 0x04 , 0x1a , 0x02 , 0x4d , 0x43 , 0x0a , 0x12 , 0x0a , 0x05 , 0x61 , 0x6c , 0x70 , 0x68 , 0x61 , 0x12 , 0x09 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xe0 , 0x3f , 0x0a , 0x0f , 0x0a , 0x02 , 0x69 , 0x64 , 0x12 , 0x09 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf0 , 0x3f , 0x0a , 0x13 , 0x0a , 0x0d , 0x6f , 0x70 , 0x74 , 0x69 , 0x6d , 0x69 , 0x73 , 0x61 , 0x74 , 0x69 , 0x6f , 0x6e , 0x73 , 0x12 , 0x02 , 0x20 , 0x00 , 0x0a , 0x0f , 0x0a , 0x02 , 0x70 , 0x31 , 0x12 , 0x09 , 0x11 , 0x9a , 0x99 , 0x99 , 0x99 , 0x99 , 0x99 , 0xb9 , 0x3f ]
6767
68- @test TensorBoardLogger. encode_bytes (session_start_content) == expected_bytes
68+ @test TensorBoardLogger. encode_bytes (session_start_content) == hparams_metadata_encoded_bytes
69+ end
6970
70- d = TensorBoardLogger. ProtoDecoder (IOBuffer (expected_bytes))
71+
72+ @testset " Decoding hparams metadata" begin
73+ expected_hparams_config = Dict {String, Any} (
74+ " id" => Float64 (1 ),
75+ " alpha" => 0.5 ,
76+ " p1" => 0.1 ,
77+ " optimisations" => false ,
78+ " method" => " MC"
79+ )
80+
81+ d = TensorBoardLogger. ProtoDecoder (IOBuffer (deepcopy (hparams_metadata_encoded_bytes)))
7182 decoded_content = PB. Codecs. decode (d, TensorBoardLogger. HP. HParamsPluginData)
7283 decoded_session_info = decoded_content. data. value
7384
74- @test all (haskey (decoded_session_info. hparams, k) for k in keys (hparams_config ))
85+ @test all (haskey (decoded_session_info. hparams, k) for k in keys (expected_hparams_config ))
7586
7687 for (k, hv) in decoded_session_info. hparams
7788 decoded_v = hv. kind. value
78- @test hparams_config [k] == decoded_v
89+ @test expected_hparams_config [k] == decoded_v
7990 end
8091end
0 commit comments