1
0
Fork 0
mirror of https://github.com/karpathy/minGPT synced 2024-05-05 15:16:10 +02:00

Merge pull request #83 from mishig25/patch-1

Use XOR operator `^` for checking assertion `type_given XOR params_given`
This commit is contained in:
Andrej 2022-07-28 17:04:56 -07:00 committed by GitHub
commit cafce4544b
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,7 @@ class GPT(nn.Module):
type_given = config.model_type is not None
params_given = all([config.n_layer is not None, config.n_head is not None, config.n_embd is not None])
assert (type_given and not params_given) or (not type_given and params_given) # exactly one of these
assert type_given ^ params_given # exactly one of these (XOR)
if type_given:
# translate from model_type to detailed configuration
config.merge_from_dict({