2018-08-23 12:47:43 +00:00
|
|
|
using Flux:onecold
|
2018-08-21 03:29:57 +00:00
|
|
|
using Test
|
|
|
|
|
2018-08-23 14:44:28 +00:00
|
|
|
@testset "onecold" begin
|
2018-08-21 03:29:57 +00:00
|
|
|
a = [1, 2, 5, 3.]
|
|
|
|
A = [1 20 5; 2 7 6; 3 9 10; 2 1 14]
|
|
|
|
labels = ['A', 'B', 'C', 'D']
|
2018-08-23 14:44:28 +00:00
|
|
|
|
2018-08-23 12:47:43 +00:00
|
|
|
@test onecold(a) == 3
|
|
|
|
@test onecold(A) == [3, 1, 4]
|
|
|
|
@test onecold(a, labels) == 'C'
|
|
|
|
@test onecold(A, labels) == ['C', 'A', 'D']
|
2018-08-21 03:29:57 +00:00
|
|
|
end
|
2019-02-09 17:02:02 +00:00
|
|
|
|
|
|
|
@testset "onehotbatch indexing" begin
|
|
|
|
y = Flux.onehotbatch(ones(3), 1:10)
|
|
|
|
@test y[:,1] isa Flux.OneHotVector
|
2019-04-04 13:46:14 +00:00
|
|
|
@test y[:,:] isa Flux.OneHotMatrix
|
2019-02-09 17:02:02 +00:00
|
|
|
end
|