Files
MeltMind/tools/phase3_item_b_model.py
T

19 lines
725 B
Python

"""Original H2 initialization plus three zero-weight input columns, +384 parameters."""
import torch
from torch import nn
from phase2_h2_model import H2Geo
class H2Context(H2Geo):
def __init__(self):
super().__init__()
# No new random draws: shared parameters and subsequent RNG match H2.
for layer in (self.encoder[0],self.head[0]):
layer.weight=nn.Parameter(torch.cat([layer.weight.detach(),layer.weight.new_zeros((64,3))],dim=1))
layer.in_features+=3
def forward(self,x,*args,**kwargs):
if x.ndim!=2 or x.shape[1]!=22:
raise ValueError('Exactly19 original plus2 context and1 validity columns')
return super().forward(x,*args,**kwargs)