@@ -19,14 +19,13 @@ public class LinearRegression : Python, IExample
1919 int training_epochs = 1000 ;
2020 int display_step = 50 ;
2121
22+ NDArray train_X , train_Y ;
23+ int n_samples ;
24+
2225 public void Run ( )
2326 {
2427 // Training Data
25- var train_X = np . array ( 3.3f , 4.4f , 5.5f , 6.71f , 6.93f , 4.168f , 9.779f , 6.182f , 7.59f , 2.167f ,
26- 7.042f , 10.791f , 5.313f , 7.997f , 5.654f , 9.27f , 3.1f ) ;
27- var train_Y = np . array ( 1.7f , 2.76f , 2.09f , 3.19f , 1.694f , 1.573f , 3.366f , 2.596f , 2.53f , 1.221f ,
28- 2.827f , 3.465f , 1.65f , 2.904f , 2.42f , 2.94f , 1.3f ) ;
29- var n_samples = train_X . shape [ 0 ] ;
28+ PrepareData ( ) ;
3029
3130 // tf Graph Input
3231 var X = tf . placeholder ( tf . float32 ) ;
@@ -95,5 +94,14 @@ public void Run()
9594 Console . WriteLine ( $ "Absolute mean square loss difference: { Math . Abs ( ( float ) training_cost - ( float ) testing_cost ) } ") ;
9695 } ) ;
9796 }
97+
98+ public void PrepareData ( )
99+ {
100+ train_X = np . array ( 3.3f , 4.4f , 5.5f , 6.71f , 6.93f , 4.168f , 9.779f , 6.182f , 7.59f , 2.167f ,
101+ 7.042f , 10.791f , 5.313f , 7.997f , 5.654f , 9.27f , 3.1f ) ;
102+ train_Y = np . array ( 1.7f , 2.76f , 2.09f , 3.19f , 1.694f , 1.573f , 3.366f , 2.596f , 2.53f , 1.221f ,
103+ 2.827f , 3.465f , 1.65f , 2.904f , 2.42f , 2.94f , 1.3f ) ;
104+ n_samples = train_X . shape [ 0 ] ;
105+ }
98106 }
99107}
0 commit comments