Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SwissArmyTransformer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
thukeg
SwissArmyTransformer
Commits
9833cc8a
Commit
9833cc8a
authored
3 years ago
by
Zhengxiao Du
Browse files
Options
Downloads
Patches
Plain Diff
Add GLM Model
parent
8584bf91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model/glm_model.py
+17
-0
17 additions, 0 deletions
model/glm_model.py
with
17 additions
and
0 deletions
model/glm_model.py
0 → 100644
+
17
−
0
View file @
9833cc8a
import
torch
import
torch.nn
as
nn
from
.base_model
import
BaseModel
class
GLMModel
(
BaseModel
):
def
__init__
(
self
,
args
,
transformer
=
None
):
super
().
__init__
(
args
,
transformer
=
transformer
)
self
.
transformer
.
block_position_embeddings
=
torch
.
nn
.
Embedding
(
args
.
max_sequence_length
,
args
.
hidden_size
)
torch
.
nn
.
init
.
normal_
(
self
.
transformer
.
block_position_embeddings
.
weight
,
mean
=
0.0
,
std
=
0.02
)
def
position_embedding_forward
(
self
,
position_ids
,
*
other_tensors
):
position_ids
,
block_position_ids
=
position_ids
[:,
0
],
position_ids
[:,
1
]
position_embeddings
=
self
.
transformer
.
position_embeddings
(
position_ids
)
block_position_embeddings
=
self
.
transformer
.
block_position_embeddings
(
block_position_ids
)
return
position_embeddings
+
block_position_embeddings
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