-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_model.jl
44 lines (38 loc) · 1.1 KB
/
check_model.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Niccolò Antonello <[email protected]>
#
# This script is mainly for testing the model input/output works correctly
#
using HMMGradients, FiniteStateTransducers
using Random, Statistics, FileIO
using BSON
setup="2a"
include("WFSTs.jl")
include("Models.jl")
include("Utils.jl")
include("conf/$(setup)/feat_conf.jl")
include("conf/$(setup)/model_conf.jl")
# get transition matrix
lexicon, ilexicon = get_lexicon()
H, L = get_HL(lexicon)
a, A = get_aA(H)
Ns = size(A,1)
# init model
modely = get_convnet(Nf,Ns;
Nks=Nks,
Nhs=Nhs,
strides=strides,
dilations=dilations,
dropout=dropout,
fout=fout)
Nt,Nb = rand(500:1000),4
x = zeros(Float32,Nt,Nf,Nb)
t,b = 500,1
x[t,:,b] .= 1.0
y = modely(x)
z = sum(y[:,:,b],dims=2)
Nt2 = ceil(Int,Nt/3)
@assert Nt2 == size(y,1)
println("Setup = $setup")
println("Num of parameters = $(sum(prod.(size.(params(modely)))))")
println("Context bins = $(subsample*sum( (!).(z .≈ z[100]) ))")