Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Shape Transformer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
Gregor Kobsik
Shape Transformer
Commits
8cf95852
Commit
8cf95852
authored
3 years ago
by
Gregor Kobsik
Browse files
Options
Downloads
Patches
Plain Diff
Rework loading of 'fast-recurrent' sampler.
parent
e85530c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sample/shape_sampler.py
+4
-4
4 additions, 4 deletions
sample/shape_sampler.py
with
4 additions
and
4 deletions
sample/shape_sampler.py
+
4
−
4
View file @
8cf95852
...
...
@@ -12,15 +12,15 @@ class ShapeSampler:
Args:
checkpoint_path: Relative or absolute path to a checkpoint file (
"
*.ckpt
"
) containing a trained model.
fast_recurrent: Changes the
'
fast
'
architecture of the Transformer into an equivalent, but recurrent
formulation durring inference time.
formulation durring inference time
, otherwise uses the standard full pass technique
.
device: Selects the device on which the sampling should be performed. Either
"
cpu
"
or
"
cuda
"
(gpu-support)
available.
"""
# load and restore model from checkpoint
if
fast_recurrent
is
True
:
pl_module
=
ShapeTransformer
.
load_from_checkpoint
(
checkpoint_path
,
architecture
=
'
fast-recurrent
'
)
else
:
pl_module
=
ShapeTransformer
.
load_from_checkpoint
(
checkpoint_path
)
if
fast_recurrent
is
True
and
pl_module
.
hparams
[
'
architecture
'
]
==
'
fast
'
:
print
(
"
Reload model as a recurrent implementation for a major improvement of inference time.
"
)
pl_module
=
ShapeTransformer
.
load_from_checkpoint
(
checkpoint_path
,
architecture
=
'
fast-recurrent
'
)
pl_module
.
freeze
()
# extract hyperparameters from the model
...
...
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