-
Notifications
You must be signed in to change notification settings - Fork 32
/
bow_embedding_simple.lua
39 lines (31 loc) · 1.17 KB
/
bow_embedding_simple.lua
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
--BOW embedding without deep network
require 'nn'
--require 'cunn'
-- IMP if args is not passed, it takes from global 'args'
return function(args)
function create_network(args)
local n_hid = args.hist_len*args.ncols*args.state_dim
local mlp = nn.Sequential()
mlp:add(nn.Reshape(args.hist_len*args.ncols*args.state_dim))
-- mlp:add(nn.Linear(args.hist_len*args.ncols*args.state_dim, n_hid))
-- mlp:add(nn.Rectifier())
-- mlp:add(nn.Linear(n_hid, n_hid))
-- mlp:add(nn.Rectifier())
local mlp_out = nn.ConcatTable()
mlp_out:add(nn.Linear(n_hid, args.n_actions))
mlp_out:add(nn.Linear(n_hid, args.n_objects))
mlp:add(mlp_out)
if args.gpu >=0 then
mlp:cuda()
end
return mlp
end
return create_network(args)
end
-- for action-object linking
-- local mlp_out = nn.ConcatTable()
-- mlp_out:add(nn.Identity())
-- local action_object_nn = nn.Sequential()
-- action_object_nn:add(nn.Linear(args.n_actions, n_hid))
-- action_object_nn:add(nn.Linear(n_hid, args.n_objects))
-- mlp_out:add(action_object_nn)