Sample-specific values are not considered model parameters. Though you can train such values, you won’t be able to make out-of-sample predictions. Perhaps you need group-specific values. In both cases, you should probably use nn.Embedding index lookups (do embedding.weight.data.zero_() as it is initialized with gaussian noise by default)