iamthinbaker commited on
Commit
fef68dd
·
verified ·
1 Parent(s): 6722095

Add model code for trust_remote_code

Browse files
Files changed (1) hide show
  1. conditioned_gpt2.py +5 -1
conditioned_gpt2.py CHANGED
@@ -16,7 +16,7 @@ class ConditionedGPT2(GPT2LMHeadModel):
16
  def __init__(
17
  self,
18
  config: GPT2Config,
19
- num_pokemon: int,
20
  noise_std: float = 0.1,
21
  row_marker_token_ids: list[int] | None = None,
22
  num_types1: int = NUM_TYPES1,
@@ -26,6 +26,10 @@ class ConditionedGPT2(GPT2LMHeadModel):
26
  token_weights: torch.Tensor | None = None,
27
  num_color_shifts: int = NUM_COLOR_SHIFTS,
28
  ):
 
 
 
 
29
  super().__init__(config)
30
  self.conditioning = nn.Embedding(num_pokemon, config.n_embd)
31
  nn.init.normal_(self.conditioning.weight, std=0.02)
 
16
  def __init__(
17
  self,
18
  config: GPT2Config,
19
+ num_pokemon: int | None = None,
20
  noise_std: float = 0.1,
21
  row_marker_token_ids: list[int] | None = None,
22
  num_types1: int = NUM_TYPES1,
 
26
  token_weights: torch.Tensor | None = None,
27
  num_color_shifts: int = NUM_COLOR_SHIFTS,
28
  ):
29
+ num_pokemon = num_pokemon or getattr(config, "num_pokemon", None)
30
+ if num_pokemon is None:
31
+ raise ValueError("num_pokemon must be provided or present in config")
32
+ config.num_pokemon = num_pokemon
33
  super().__init__(config)
34
  self.conditioning = nn.Embedding(num_pokemon, config.n_embd)
35
  nn.init.normal_(self.conditioning.weight, std=0.02)