Skip to content

Commit 1ff476d

Browse files
Merge branch 'main' into gradient
2 parents fa9c07d + 2ba7bb2 commit 1ff476d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __API Changes__:
1414
__Bug Fixes__:
1515

1616
- #1300 `Adadelta`, `Adam` and `AdamW` will no longer throw `NullReferenceException` when `maximize` is `true` and `grad` is `null`.
17+
- `torch.normal` will now correctly return a leaf tensor.
1718

1819
# NuGet Version 0.102.4
1920

src/TorchSharp/Tensor/Factories/Tensor.Factories.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public static Tensor eye(long rows, long columns = -1L, ScalarType? dtype = null
116116
/// <returns></returns>
117117
public static Tensor normal(double mean, double std, ReadOnlySpan<long> size, ScalarType? dtype = null, Device? device = null, bool requires_grad = false, Generator? generator = null, string[]? names = null)
118118
{
119-
return randn(size, dtype: dtype, device: device, requires_grad: requires_grad, generator: generator) * std + mean;
119+
return randn(size, dtype, device, requires_grad: false, generator, names)
120+
.mul_(std).add_(mean).requires_grad_(requires_grad);
120121
}
121122

122123
/// <summary>

0 commit comments

Comments
 (0)