Skip to content

Commit

Permalink
Updated the custom_models.md changed cross_entropy code (huggingface#…
Browse files Browse the repository at this point in the history
  • Loading branch information
S-M-J-I authored and zucchini-nlp committed Aug 30, 2024
1 parent 5c141af commit ab6d35f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/source/en/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/es/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/it/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/ja/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/ko/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pt/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh/custom_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
def forward(self, tensor, labels=None):
logits = self.model(tensor)
if labels is not None:
loss = torch.nn.cross_entropy(logits, labels)
loss = torch.nn.functional.cross_entropy(logits, labels)
return {"loss": loss, "logits": logits}
return {"logits": logits}
```
Expand Down

0 comments on commit ab6d35f

Please sign in to comment.