boathit/t2vec

Haven't found the definition of "injectnoise()"

Closed this issue · 2 comments

Hi, I'm new to Julia and I noticed that injectnoise() was used without exactly defined.
All I found throughout the codes with the "injectnoise" are only two lines:L311,L325

function createTrainVal(region::SpatialRegion,
trjfile::String,
injectnoise::Function,
ntrain::Int,
nval::Int;
nsplit=5,
min_length=20,
max_length=100)
seq2str(seq) = join(map(string, seq), " ") * "\n"
h5open(trjfile, "r") do f
trainsrc, traintrg = open("../data/train.src", "w"), open("../data/train.trg", "w")
validsrc, validtrg = open("../data/val.src", "w"), open("../data/val.trg", "w")
for i = 1:ntrain+nval
trip = f["/trips/$i"] |> read
min_length <= size(trip, 2) <= max_length || continue
trg = trip2seq(region, trip) |> seq2str
noisetrips = injectnoise(trip, nsplit)

The code works, so I must have some misunderstanding there.
Could anyone tell me where I am wrong?

injectnoise is an argument of createTrainVal, i.e., it is a variable and can be any function you pass to createTrainVal. For example, the call createTrainVal(region, "porto.h5", downsampling, 50, 10) instantiates injectnoise to be downsampling which is defined here.

Thanks for your quick reply! I just realized what a simply question I asked. Thx!