Skip to content

Commit 6194711

Browse files
committed
Fix sample
1 parent b09c2e4 commit 6194711

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

SampleTest/SampleTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,10 @@ void LinearRegression ()
291291
var X = g.Placeholder (TFDataType.Float);
292292
var Y = g.Placeholder (TFDataType.Float);
293293

294-
var W = g.Variable (g.Const ((float)rng.Next ()), operName: "weight");
295-
var b = g.Variable (g.Const ((float) rng.Next ()), operName: "bias");
296-
var pred = g.Add (g.Mul (X, W, "x*w"), b);
294+
TFOutput readW, readB;
295+
var W = g.Variable (g.Const ((float)rng.Next ()), out readW, operName: "weight");
296+
var b = g.Variable (g.Const ((float) rng.Next ()), out readB, operName: "bias");
297+
var pred = g.Add (g.Mul (X, readW, "x*w"), readB);
297298

298299
var first = g.Pow (g.Sub (pred, Y), g.Const ((float)2));
299300
var cost = g.Div (g.ReduceSum (g.Pow (g.Sub (pred, Y), g.Const (2f))), g.Mul (g.Const (2f), g.Const ((float)n_samples), "2*n_samples"));

0 commit comments

Comments
 (0)