File tree 2 files changed +12
-2
lines changed
official/projects/pix2seq
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ class BackboneConfig(hyperparams.Config):
115
115
)
116
116
# Optional checkpoint to load for this backbone.
117
117
init_checkpoint : Optional [str ] = None
118
+ # If loading an init_checkpoint, whether to assert that all objects in the
119
+ # Python program are matched by the checkpoint.
120
+ # If False, understand that only the weak assertion of a non-trivial match
121
+ # will be made.
122
+ assert_existing_objects_matched : bool = True
118
123
119
124
120
125
@dataclasses .dataclass
Original file line number Diff line number Diff line change @@ -141,8 +141,13 @@ def initialize(self, model: tf_keras.Model):
141
141
backbone .load_checkpoint (ckpt_filepath = backbone_init_ckpt )
142
142
else :
143
143
ckpt = tf .train .Checkpoint (backbone = backbone )
144
- status = ckpt .restore (backbone_init_ckpt )
145
- status .expect_partial ().assert_existing_objects_matched ()
144
+ status = (
145
+ ckpt .restore (backbone_init_ckpt )
146
+ .expect_partial ()
147
+ .assert_nontrivial_match ()
148
+ )
149
+ if backbone_config .assert_existing_objects_matched :
150
+ status .assert_existing_objects_matched ()
146
151
147
152
logging .info (
148
153
'Finished loading pretrained backbone from %s' , backbone_init_ckpt
You can’t perform that action at this time.
0 commit comments