aboutsummaryrefslogtreecommitdiff
path: root/fastnn/io/example.lua
blob: 8808791c062685af012e829aea9613acd9a564d9 (plain) (blame)
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
local T =  require 'libthreads'
local C =  require 'libfastnn' 

local ExamplesRepo = nerv.class("fastnn.ExamplesRepo")
local Example = nerv.class("fastnn.Example")

fastnn.CExamplesRepo = C.CExamplesRepo
fastnn.CExample = C.CExample

function ExamplesRepo:__init(shareid)
	if nil ~= shareid then
		-- print(shareid)
		self.repo = C.CExamplesRepo(shareid, true)
		-- print(self.repo:__tostring())
	end
end	
		

function Example:PrepareData(data, global_transf, trains_id)
	local example = fastnn.CExample()
	if nil ~= data then
		for id, cm in pairs(data) do
			if trains_id[id] and nil ~= global_transf then
				local tcm = nerv.speech_utils.normalize(cm, global_transf)
				example:pushback(tcm)
			else
				example:pushback(cm)
			end

		end
	end

	return example
end