-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmodelClass.lua
More file actions
82 lines (68 loc) · 2.47 KB
/
Copy pathmodelClass.lua
File metadata and controls
82 lines (68 loc) · 2.47 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
----------------------------------------------------------------------
--
-- Deep time series learning: Analysis of Torch
--
-- Main definition of the model class
-- * Synthesize the basic functionalities of most models
-- * Allows to
-- * Will define basic train / test functions
--
----------------------------------------------------------------------
----------------------------------------------------------------------
-- Imports
-- local class = require 'class'
require 'torch'
require 'mainLearning'
-- Defining the main model class
local modelClass = torch.class('modelClass');
--- This function defines the construction for the structure of a learning model
--
-- The code takes a particular network topology (given as a lua table)
-- with a set of options and outputs a model compatible with nn.Module
--
-- @param structure Network topology (size) (Table)
-- @param options Sets of options (Table)
-- @return model The constructed model (nn.Module)
-- @usage model = register_person('john','doe')
-- @see Person
--
function modelClass:defineModel(structure, options)
end
-- Set the default parameters
function modelClass:parametersDefault()
end
-- Set a set of parameters (coming from hyper-parameter optimization)
function modelClass:parametersSet(parameters)
end
-- Defines the structure of eventual pre-training model
function modelClass:definePretraining(structure, l, options)
end
-- Function to perform unsupervised training on a sub-model
function modelClass:unsupervisedTrain(model, unsupData, options)
return unsupervisedTrain(model, unsupData, options);
end
-- Function to perform unsupervised testing on a sub-model
function modelClass:unsupervisedTest(model, data, options)
return unsupervisedTest(model, data, options);
end
-- Function to perform supervised training on the full model
function modelClass:supervisedTrain(model, data, options)
return supervisedTrain(model, data, options);
end
-- Function to perform supervised testing on the model
function modelClass:supervisedTest(model, data, options)
return supervisedTest(model, data, options);
end
function modelClass:defineCriterion(model)
model:add(nn.LogSoftMax());
criterion = nn.ClassNLLCriterion();
return model, criterion;
end
function modelClass:getParameters(model)
return model:getParameters();
end
-- Transfer the weights from pre-training to the final model
function modelClass:weightsTransfer(model, trainedLayers)
end
function modelClass:weightsInitialize(model)
end