Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NLP_CW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Park, Se
NLP_CW
Commits
79c7877c
Commit
79c7877c
authored
5 years ago
by
Park, Se
Browse files
Options
Downloads
Patches
Plain Diff
Delete model.py
parent
90c0fdfe
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model.py
+0
-35
0 additions, 35 deletions
model.py
with
0 additions
and
35 deletions
model.py
deleted
100644 → 0
+
0
−
35
View file @
90c0fdfe
import
torch
import
torch.nn
as
nn
import
torch.nn.functional
as
F
from
transformers
import
BertModel
,
BertConfig
class
QualityEstimation
(
nn
.
Module
):
def
__init__
(
self
,
hidden_dim
):
super
(
QualityEstimation
,
self
).
__init__
()
self
.
hidden_dim
=
hidden_dim
# Instantiating BERT model object
config
=
BertConfig
()
self
.
bert
=
BertModel
(
config
).
from_pretrained
(
'
bert-base-multilingual-cased
'
)
self
.
dropout
=
nn
.
Dropout
(
0.25
)
# LSTM and classification layers
self
.
lstm
=
nn
.
LSTM
(
input_size
=
768
,
hidden_size
=
self
.
hidden_dim
,
num_layers
=
1
,
batch_first
=
True
,
dropout
=
0
,
bidirectional
=
False
)
self
.
fc1
=
nn
.
Linear
(
self
.
hidden_dim
,
1
)
nn
.
init
.
kaiming_normal_
(
self
.
fc1
.
weight
)
# self.fc2 = nn.Linear(self.hidden_dim, 1)
# nn.init.kaiming_normal_(self.fc2.weight)
def
forward
(
self
,
token_ids
,
segment_ids
=
None
,
attention_mask
=
None
):
encoded_layers
,
_
=
self
.
bert
(
input_ids
=
token_ids
,
token_type_ids
=
segment_ids
,
attention_mask
=
attention_mask
)
encoded_layers
=
self
.
dropout
(
encoded_layers
)
output
,
_
=
self
.
lstm
(
encoded_layers
)
# output = torch.tanh(self.fc1(output[:,-1,:]))
qe_scores
=
self
.
fc1
(
output
[:,
-
1
,:])
# qe_scores = torch.tanh(qe_scores)
return
qe_scores
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment