Upload train.py with huggingface_hub
Browse files201 unmodified lines202203204205206207208201 unmodified linesx,y = x.to(device), y.to(device); B=x.shape[0]lg_no,lg_fb,rl = model.forward_both(x)def chunked_ce(logits,targets):V_=logits.shape[-1]; logits=logits.view(-1,V_); targets=targets.reshape(-1)total=0.0for i in range(0,V_,16384): total=total+F.cross_entropy(logits[:,i:i+16384],targets,reduction='sum')return total/targets.numel()201 unmodified lines202203204205206207208201 unmodified linesx,y = x.to(device), y.to(device); B=x.shape[0]lg_no,lg_fb,rl = model.forward_both(x)def chunked_ce(logits,targets):V_=logits.shape[-1]; logits=logits.view(-1,V_); targets=targets.reshape(-1).clamp(0,V_-1)total=0.0for i in range(0,V_,16384): total=total+F.cross_entropy(logits[:,i:i+16384],targets,reduction='sum')return total/targets.numel()
train.py+1-1