removed deepcopy, delete expendable parameters after use

This commit is contained in:
Brett Kuprel
2022-06-30 11:09:09 -04:00
parent 41a44068d0
commit b55bcba4c0
3 changed files with 13 additions and 8 deletions
+7 -3
View File
@@ -28,7 +28,7 @@ class MinDalleFlax(MinDalleBase):
text_token_count = self.config['max_text_length'],
text_vocab_count = self.config['encoder_vocab_size'],
layer_count = self.config['encoder_layers']
).bind({'params': self.model_params['encoder']})
).bind({'params': self.model_params.pop('encoder')})
def init_decoder(self):
@@ -53,13 +53,17 @@ class MinDalleFlax(MinDalleBase):
encoder_state = self.encoder(text_tokens)
if self.is_expendable: del self.encoder
if self.is_expendable: self.init_decoder()
if self.is_expendable:
self.init_decoder()
params = self.model_params.pop('decoder')
else:
params = self.model_params['decoder']
print("sampling image tokens")
image_tokens = self.decoder.sample_image_tokens(
text_tokens,
encoder_state,
jax.random.PRNGKey(seed),
self.model_params['decoder']
params
)
if self.is_expendable: del self.decoder