(self)
| 163 | return obj |
| 164 | |
| 165 | def _init_text_components(self): |
| 166 | |
| 167 | if self.vtp_config.training.train_clip: |
| 168 | text = _build_text_tower_from_config(self.vtp_config) |
| 169 | self.transformer = text.transformer |
| 170 | self.context_length = text.context_length |
| 171 | self.vocab_size = text.vocab_size |
| 172 | self.token_embedding = text.token_embedding |
| 173 | self.positional_embedding = text.positional_embedding |
| 174 | self.ln_final = text.ln_final |
| 175 | self.text_projection = text.text_projection |
| 176 | self.text_pool_type = text.pool_type |
| 177 | self.register_buffer('attn_mask', text.attn_mask, persistent=False) |
| 178 | |
| 179 | init_logit_scale = self.vtp_config.training.init_logit_scale or np.log(1 / 0.07) |
| 180 | init_logit_bias = self.vtp_config.training.init_logit_bias |
| 181 | nonscalar_logit_scale = self.vtp_config.training.nonscalar_logit_scale |
| 182 | |
| 183 | lshape = [1] if nonscalar_logit_scale else [] |
| 184 | self.logit_scale = nn.Parameter(torch.ones(lshape) * init_logit_scale) |
| 185 | if init_logit_bias is not None: |
| 186 | self.logit_bias = nn.Parameter(torch.ones(lshape) * init_logit_bias) |
| 187 | else: |
| 188 | self.logit_bias = None |
| 189 | self.output_dict = self.vtp_config.training.clip_output_dict |
| 190 | else: |
| 191 | logging.info("Not training clip") |
| 192 | |
| 193 | |
| 194 | def _init_vision_components(self): |
no test coverage detected