forked from Wangt-CN/MTFN-RR-PyTorch-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseq2vec.py
25 lines (22 loc) · 894 Bytes
/
seq2vec.py
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
# -----------------------------------------------------------
# "Matching Images and Text with Multi-modal Tensor Fusion and Re-ranking"
# WangTan, XingXu, YangYang, Alan Hanjalic, HengtaoShen, JingkuanSong
# ACM Multimedia 2019, Nice, France
# Writen by WangTan, 2019
# ------------------------------------------------------------
# A revision version from Skip-thoughs
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import skipthoughts
def factory(vocab_words, opt):
if opt['arch'] == 'skipthoughts':
st_class = getattr(skipthoughts, opt['type'])
seq2vec = st_class(opt['dir_st'],
vocab_words,
dropout=opt['dropout'],
fixed_emb=opt['fixed_emb'])
else:
raise NotImplementedError
return seq2vec