Regression
In this example we implement a logistic regression based binary classifier and train it to distinguish between the MNIST digits of 0 and 1.
Loading the data
First, let's start by loading the MNIST training and testing data and arranging these into training, validation, and testing sets.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
|
open Hype
open Hype.Neural
open DiffSharp.AD.Float32
open DiffSharp.Util
let MNIST = Dataset(Util.LoadMNISTPixels("C:/datasets/MNIST/train-images.idx3-ubyte", 60000),
Util.LoadMNISTLabels("C:/datasets/MNIST/train-labels.idx1-ubyte", 60000) |> toDV |> DM.ofDV 1).NormalizeX()
let MNISTtrain = MNIST.[..58999]
let MNISTvalid = MNIST.[59000..]
let MNISTtest = Dataset(Util.LoadMNISTPixels("C:/datasets/MNIST/t10k-images.idx3-ubyte", 10000),
Util.LoadMNISTLabels("C:/datasets/MNIST/t10k-labels.idx1-ubyte", 10000) |> toDV |> DM.ofDV 1).NormalizeX()
|
We shuffle the columns of the datasets and filter them to only keep the digits of 0 and 1.
1:
2:
3:
|
let MNISTtrain01 = MNISTtrain.Shuffle().Filter(fun (x, y) -> y.[0] <= D 1.f)
let MNISTvalid01 = MNISTvalid.Shuffle().Filter(fun (x, y) -> y.[0] <= D 1.f)
let MNISTtest01 = MNISTtest.Shuffle().Filter(fun (x, y) -> y.[0] <= D 1.f)
|
val MNISTtrain01 : Dataset = Hype.Dataset
X: 784 x 12465
Y: 1 x 12465
val MNISTvalid01 : Dataset = Hype.Dataset
X: 784 x 200
Y: 1 x 200
val MNISTtest01 : Dataset = Hype.Dataset
X: 784 x 2115
Y: 1 x 2115
We can visualize individual digits from the dataset.
1:
2:
|
MNISTtrain.X.[*,9] |> DV.visualizeAsDM 28 |> printfn "%s"
MNISTtrain.Y.[*,9]
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
|
DM : 28 x 28
♦♦
▪█▪
▴██·
♦█♦
● ·█■
■█ ■█·
♦█ ██·
▴█■ ●█♦
■█ ▪█■
■█▪ ▴██-
-███♦▴ ♦█▪
·███■██♦■█■
·██■ ♦█████■
♦■- ♦████▪
- ██·
▪█■
▴█■
■█▴
■█▪
▴█·
val it : DV = DV [|4.0f|]
|
We can also visualize a series of digits in grid layout.
1:
|
MNISTtrain.[..5].VisualizeXColsAsImageGrid(28) |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
|
Hype.Dataset
X: 784 x 6
Y: 1 x 6
X's columns reshaped to (28 x 28), presented in a (2 x 3) grid:
DM : 56 x 84
▪█▪
▴▴● ●██▴ █████ ■
-▪●█████■●██♦ ■███■█ · ▴●
██████████-·· ■███♦·██▴ ▴● ▪♦
■█████♦●██ ●██████-♦█● ■● █▪
·▪-██♦ ▪ ███♦-█■ ·█● ■● ●█▴
▪█· ███● ·▴ ██ █● ♦█
▴█♦ ●█■♦· ██● ▴█● ■█
♦█· ●██· ██♦ ▪█▴ ●█■
█■▪- ██ ██♦ ▪█ ·●██·
·███▴ ♦█♦ ██♦ ▪█· ▴▪▪███●██
●██▪ ·██- ██▪ ▪██♦♦♦████♦▪· ■█
-██♦ ·█■ ▴█● ▴●●●●●- -█■
███ ·█■ ▴█■· ●█▴
▴●██♦ ·█▪ ●█● ●█
▪■████● ·█■ -██▪ ●█
-■████♦· ·██▪ ·●■█■● ●█-
■████♦· ·███■■███♦▴ ●█-
●■████♦· ♦█████■▪ ●█▪
●■█████▴ ▴███▪ ●█▪
▴███■▴▴ -█▪
▴██ -▴
-███ ▪♦███▪
▴███ ▪♦██-·▪ ▪███■■█■
██■ ·■██♦♦███● ▪████■ ██
■██- ██♦ ●██▴ -████■ ██
▪██♦ -██● ·██■ ●██■● ·██
███ ▴██▪ ■██· ▴ -██
♦██▴ ▴██● ·██▴ ▪██
-██● ■█● ♦██● -▴▴▴♦█♦
·██♦ ██ ▴♦████· ●█████■
███▪ ■█████■■█■ ■██■●███■▴
▪███ ██■▴ ♦█▪ ·██▴ ♦████·
■██● ██- ▴██● ♦██▴●██●
███♦ ·██ ▴██- ♦█■ ·●███■
███· ██ -██· ·●██▴ ·●●
▪███ ·██ ■██♦■███▴
■██▪ -██ ♦████●▴
██■ ██ -▪▴
██■ ■█
♦█■ -█♦
●█●
▪█
|
1:
|
MNISTtrain01.[..5].VisualizeXColsAsImageGrid(28) |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
|
Hype.Dataset
X: 784 x 6
Y: 1 x 6
X's columns reshaped to (28 x 28), presented in a (2 x 3) grid:
DM : 56 x 84
▴●███- ·♦██
·▪■█████■ ████● -▪██████
▪████████- ●████■ ▪██████████
●████▪ ●███▴ ■████● ■███■▪▪▴-███●
████● ▴███· ██████ -███■ ██████
███▪ ██▴ -██████ ■██▴ ████▴♦-
■██· ●█● ▪█████■ ■██ ■█▴█■
●██· ▴█● ██████ ▪██● - ■█-
-██▪ ▴█● ██████ ██■ ▪█▴
██■ ▴█● ■█████▴ ▴██- ■█▴
·██ ▴█● ██████- ▴██ ██▴
■█■ ▴█● █████▴ ▴█■ ██
■█▪ ▴█● ♦████- ▴█▪ ▴█▪
██- ●█● ♦█████ ▴█▪ ●█·
██▴ ██· █████♦ -██ -█▪
███ ●██· ●█████· ██■ █-
-███● ▴██● ·█████ ███ ■■
■█████♦●●■███■ ♦█████ ██- -■█·
▴■█████████♦ █████♦ ●██● -■██▪
·▪▪●█♦▪▴ ▴████· ●████████■-
▪█████▪-
■▴ ·····
▴■ ▪■█████·
♦♦♦♦♦-· ■█ ▴█████████-
▪████████■▪ ██ ███████████·
■███████████■ ▪█■ ▴■████♦♦ ▴████
█████████ ♦███ ██- ▴████♦▴ ■███·
▪███● ● ·██■ █● ▴████■ ♦███-
██■ -██· ▪█▴ ████▪ ████
▪██ ██♦ ██ ███- ████
●█♦ ▪██ ▪██ ·███· ████
██▴ ▴██ ●██ ·███♦ ▪████
██ ♦█▪ ██● ·███ ▪████·
██- ██ ██· ●███ ·●█████·
♦█● ■██ ·██- ████· ■██████▴
▪█■ ■██- █♦ ████■▴▴▴■████████▪
-██● ▴███♦ -█♦ ■██████████████♦
♦██♦-▪ ▪♦██■- ■█♦ ·████████████▪▴
♦███████████● ■█- -█████████▴
▴■█■■■■■■· █■ ▪ ▪▪
♦▴
|
Defining the model
Let's now create our linear regression model. We implement this using the Hype.Neural module, as a linear layer with \(28 \times 28 = 784\) inputs and one output. The output of the layer is passed through the sigmoid function.
1:
2:
3:
|
let n = Neural.FeedForward()
n.Add(Linear(28 * 28, 1))
n.Add(sigmoid)
|
We can visualize the initial state of the linear model weights before the training. For information of about weight initialization parameters, please see the neural networks example.
1:
2:
|
let l = (n.[0] :?> Linear)
l.VisualizeWRowsAsImageGrid(28) |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
|
Hype.Neural.Linear
784 -> 1
Learnable parameters: 785
Init: Standard
W's rows reshaped to (28 x 28), presented in a (1 x 1) grid:
DM : 28 x 28
▴▪●●-█▴♦♦● ·▴█● ● ▴· ●●●●▪·
■ █- ▴●●▪ ■♦· ■▪■▪ █ ♦■●■
♦■ █♦●▪●♦ ♦■ ♦ ■ ▪- ■
■▪ ■♦■♦ █ ▪● ♦▪▴··■█ -▴●▪▪●
██··▴●●█▪♦■ -·█■ ▪- ··▪· ██
- ▪ ♦ ▪● ▪■█♦- ▴▪ ▴· ▪·●
- ●●▴▴ ▪■ ▴█ ▪▴·▴▴·♦■■♦·■■
♦▴ ▪■ ▪▪▴■·■--▪♦- ·♦▪■ ♦·●
·▴·♦▪♦●▪··▴·▪ ● ▪ █ ▴▪·♦▪
■ ▴ ♦█▴ - ♦●■ █▪■●▪█■▴●--█
♦■ ●■▴♦ ●· █· ▴· -█-▪●■■-■
█-·▪▴-▴█ ♦ █●·♦█▪▪●●■ - ·
- █ ■♦·●▪▴♦ -▴ - ■♦· ♦ -
■█ ▪- ▪■●♦█▴-█▪■ ■♦▪█■▪■ -
●♦█▴♦♦ ♦ ▴▪▴▴♦-▴♦♦█ ▴ ▪·●
·█▪■■█ ●· ●· -●■●·· ▴ --▴
·♦█▴ ♦♦■ ▴▪●▪- · -♦●♦ ■ · ■
■■▪---♦■·●▴▪-▪▴· ▪●● ·♦■ ▪♦▴
▴ -♦●■█·█ ● ♦▪●■- ·■♦-▪▴■▴
●-■● ···●█▴▪ -█·▪ ♦▴ ● ●
·█ █▴ ·♦---■▴·█■■▴ ▴■ - █
- ▪ ●█·▴♦▪ ■ ▪■ ■··· ▴
■ ♦♦- █▪♦-- ▴ ▴ ··█▴● ■♦
■·■■▪▴-·█♦●■ ▴ ♦ ♦▴■♦ ■ ●♦▪
·█▪- ■●▴▪▴▪ ▪ ▴▪ · ▪▴▴··♦
▪█♦■ ·♦ ■▪ ♦ ▴·●█▪· ·▪▴
· ■♦▪■ ▪■● ♦ ··· ·▪█■· ▪■●
●▴▪ ·■● -█●█·▪■▴ ▴▴♦ ■ ■ ▴
b:
DV : 1
|
Training
Let's train the model for 10 epochs (full passes through the training data), with a minibatch size of 100, using the training and validation sets we've defined. The validation set will make sure that we're not overfitting the model.
1:
2:
3:
4:
5:
6:
|
let p = {Params.Default with
Epochs = 10;
Batch = Minibatch 100;
EarlyStopping = EarlyStopping.DefaultEarly}
n.Train(MNISTtrain01, MNISTvalid01, p)
|
[12/11/2015 20:21:12] --- Training started
[12/11/2015 20:21:12] Parameters : 785
[12/11/2015 20:21:12] Iterations : 1240
[12/11/2015 20:21:12] Epochs : 10
[12/11/2015 20:21:12] Batches : Minibatches of 100 (124 per epoch)
[12/11/2015 20:21:12] Training data : 12465
[12/11/2015 20:21:12] Validation data: 200
[12/11/2015 20:21:12] Valid. interval: 10
[12/11/2015 20:21:12] Method : Gradient descent
[12/11/2015 20:21:12] Learning rate : RMSProp a0 = D 0.00100000005f, k = D 0.899999976f
[12/11/2015 20:21:12] Momentum : None
[12/11/2015 20:21:12] Loss : L2 norm
[12/11/2015 20:21:12] Regularizer : L2 lambda = D 9.99999975e-05f
[12/11/2015 20:21:12] Gradient clip. : None
[12/11/2015 20:21:12] Early stopping : Stagnation thresh. = 750, overfit. thresh. = 10
[12/11/2015 20:21:12] Improv. thresh.: D 0.995000005f
[12/11/2015 20:21:12] Return best : true
[12/11/2015 20:21:12] 1/10 | Batch 1/124 | D 4.748471e-001 [- ] | Valid D 4.866381e-001 [- ] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 11/124 | D 2.772053e-001 [↓▼] | Valid D 3.013612e-001 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 21/124 | D 2.178165e-001 [↓▼] | Valid D 2.304372e-001 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 31/124 | D 2.009703e-001 [↓▼] | Valid D 1.799015e-001 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 41/124 | D 1.352896e-001 [↓▼] | Valid D 1.405802e-001 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 51/124 | D 1.182899e-001 [↓▼] | Valid D 1.108390e-001 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 61/124 | D 1.124191e-001 [↓▼] | Valid D 8.995526e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 71/124 | D 8.975799e-002 [↓▼] | Valid D 7.361954e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 81/124 | D 5.031444e-002 [↓▼] | Valid D 5.941865e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 91/124 | D 5.063754e-002 [↑ ] | Valid D 4.927430e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 101/124 | D 3.842642e-002 [↓▼] | Valid D 4.095582e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 111/124 | D 4.326219e-002 [↑ ] | Valid D 3.452797e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 1/10 | Batch 121/124 | D 2.585407e-002 [↓▼] | Valid D 2.788338e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 1/124 | D 3.069563e-002 [↑ ] | Valid D 2.663207e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 11/124 | D 1.765305e-002 [↓▼] | Valid D 2.332163e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 21/124 | D 2.314118e-002 [↑ ] | Valid D 1.902804e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 31/124 | D 3.177435e-002 [↑ ] | Valid D 1.691620e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 41/124 | D 2.219648e-002 [↓ ] | Valid D 1.455527e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 51/124 | D 1.205402e-002 [↓▼] | Valid D 1.240637e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 61/124 | D 3.891717e-002 [↑ ] | Valid D 1.189688e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 71/124 | D 2.114762e-002 [↓ ] | Valid D 1.083007e-002 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 81/124 | D 5.075417e-003 [↓▼] | Valid D 9.630994e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:12] 2/10 | Batch 91/124 | D 1.343214e-002 [↑ ] | Valid D 8.666289e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 2/10 | Batch 101/124 | D 6.054885e-003 [↓ ] | Valid D 8.039203e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 2/10 | Batch 111/124 | D 1.964125e-002 [↑ ] | Valid D 7.339509e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 2/10 | Batch 121/124 | D 4.401092e-003 [↓▼] | Valid D 6.376633e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 1/124 | D 7.068173e-003 [↑ ] | Valid D 6.426438e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 11/124 | D 3.763680e-003 [↓▼] | Valid D 6.076077e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 21/124 | D 9.855231e-003 [↑ ] | Valid D 5.091224e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 31/124 | D 1.263964e-002 [↑ ] | Valid D 4.641499e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 41/124 | D 1.205439e-002 [↓ ] | Valid D 4.599225e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 51/124 | D 2.941387e-003 [↓▼] | Valid D 4.381890e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 61/124 | D 2.546543e-002 [↑ ] | Valid D 4.439059e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 71/124 | D 9.878366e-003 [↓ ] | Valid D 4.358966e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 81/124 | D 1.868963e-003 [↓▼] | Valid D 3.960044e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 91/124 | D 7.171181e-003 [↑ ] | Valid D 3.634899e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 101/124 | D 2.681098e-003 [↓ ] | Valid D 3.636524e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 111/124 | D 1.502046e-002 [↑ ] | Valid D 3.393996e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 3/10 | Batch 121/124 | D 2.381395e-003 [↓ ] | Valid D 3.178693e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 1/124 | D 3.185510e-003 [↑ ] | Valid D 3.240891e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 11/124 | D 2.029225e-003 [↓ ] | Valid D 3.163968e-003 [↓ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 21/124 | D 6.450378e-003 [↑ ] | Valid D 2.772849e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 31/124 | D 7.448227e-003 [↑ ] | Valid D 2.572560e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 41/124 | D 9.700718e-003 [↑ ] | Valid D 2.693694e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:13] 4/10 | Batch 51/124 | D 1.799919e-003 [↓▼] | Valid D 2.737873e-003 [↑ ] | Stag: 20 Ovfit: 1
[12/11/2015 20:21:13] 4/10 | Batch 61/124 | D 1.919956e-002 [↑ ] | Valid D 2.778393e-003 [↑ ] | Stag: 30 Ovfit: 3
[12/11/2015 20:21:13] 4/10 | Batch 71/124 | D 5.462923e-003 [↓ ] | Valid D 2.870561e-003 [↑ ] | Stag: 40 Ovfit: 3
[12/11/2015 20:21:13] 4/10 | Batch 81/124 | D 1.455469e-003 [↓▼] | Valid D 2.632472e-003 [↓ ] | Stag: 50 Ovfit: 4
[12/11/2015 20:21:14] 4/10 | Batch 91/124 | D 5.270801e-003 [↑ ] | Valid D 2.455564e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 4/10 | Batch 101/124 | D 2.057914e-003 [↓ ] | Valid D 2.511977e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:14] 4/10 | Batch 111/124 | D 1.314815e-002 [↑ ] | Valid D 2.393763e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 4/10 | Batch 121/124 | D 2.033168e-003 [↓ ] | Valid D 2.358985e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 1/124 | D 2.199435e-003 [↑ ] | Valid D 2.389120e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 11/124 | D 1.668178e-003 [↓ ] | Valid D 2.356529e-003 [↓ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 21/124 | D 5.649061e-003 [↑ ] | Valid D 2.151499e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 31/124 | D 5.264180e-003 [↓ ] | Valid D 2.038927e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 41/124 | D 8.416546e-003 [↑ ] | Valid D 2.145057e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 51/124 | D 1.564733e-003 [↓ ] | Valid D 2.208556e-003 [↑ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 61/124 | D 1.581773e-002 [↑ ] | Valid D 2.233998e-003 [↑ ] | Stag: 30 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 71/124 | D 3.898179e-003 [↓ ] | Valid D 2.347554e-003 [↑ ] | Stag: 40 Ovfit: 0
[12/11/2015 20:21:14] 5/10 | Batch 81/124 | D 1.395002e-003 [↓▼] | Valid D 2.182974e-003 [↓ ] | Stag: 50 Ovfit: 1
[12/11/2015 20:21:14] 5/10 | Batch 91/124 | D 4.450763e-003 [↑ ] | Valid D 2.069927e-003 [↓ ] | Stag: 60 Ovfit: 1
[12/11/2015 20:21:14] 5/10 | Batch 101/124 | D 1.927794e-003 [↓ ] | Valid D 2.129479e-003 [↑ ] | Stag: 70 Ovfit: 1
[12/11/2015 20:21:14] 5/10 | Batch 111/124 | D 1.238949e-002 [↑ ] | Valid D 2.059099e-003 [↓ ] | Stag: 80 Ovfit: 1
[12/11/2015 20:21:14] 5/10 | Batch 121/124 | D 1.969593e-003 [↓ ] | Valid D 2.072177e-003 [↑ ] | Stag: 90 Ovfit: 1
[12/11/2015 20:21:14] 6/10 | Batch 1/124 | D 1.885590e-003 [↓ ] | Valid D 2.087292e-003 [↑ ] | Stag:100 Ovfit: 1
[12/11/2015 20:21:14] 6/10 | Batch 11/124 | D 1.577425e-003 [↓ ] | Valid D 2.074389e-003 [↓ ] | Stag:110 Ovfit: 1
[12/11/2015 20:21:14] 6/10 | Batch 21/124 | D 5.410788e-003 [↑ ] | Valid D 1.943973e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 6/10 | Batch 31/124 | D 4.188792e-003 [↓ ] | Valid D 1.863442e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:14] 6/10 | Batch 41/124 | D 7.516511e-003 [↑ ] | Valid D 1.951990e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:14] 6/10 | Batch 51/124 | D 1.510475e-003 [↓ ] | Valid D 2.003860e-003 [↑ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:14] 6/10 | Batch 61/124 | D 1.375423e-002 [↑ ] | Valid D 2.020531e-003 [↑ ] | Stag: 30 Ovfit: 0
[12/11/2015 20:21:14] 6/10 | Batch 71/124 | D 3.260145e-003 [↓ ] | Valid D 2.129138e-003 [↑ ] | Stag: 40 Ovfit: 0
[12/11/2015 20:21:15] 6/10 | Batch 81/124 | D 1.402565e-003 [↓ ] | Valid D 2.002138e-003 [↓ ] | Stag: 50 Ovfit: 0
[12/11/2015 20:21:15] 6/10 | Batch 91/124 | D 3.999386e-003 [↑ ] | Valid D 1.920336e-003 [↓ ] | Stag: 60 Ovfit: 0
[12/11/2015 20:21:15] 6/10 | Batch 101/124 | D 1.929424e-003 [↓ ] | Valid D 1.976652e-003 [↑ ] | Stag: 70 Ovfit: 0
[12/11/2015 20:21:15] 6/10 | Batch 111/124 | D 1.205915e-002 [↑ ] | Valid D 1.926643e-003 [↓ ] | Stag: 80 Ovfit: 0
[12/11/2015 20:21:15] 6/10 | Batch 121/124 | D 1.978536e-003 [↓ ] | Valid D 1.951888e-003 [↑ ] | Stag: 90 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 1/124 | D 1.769614e-003 [↓ ] | Valid D 1.959661e-003 [↑ ] | Stag:100 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 11/124 | D 1.555518e-003 [↓ ] | Valid D 1.955613e-003 [↓ ] | Stag:110 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 21/124 | D 5.217655e-003 [↑ ] | Valid D 1.861573e-003 [↓ ] | Stag:120 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 31/124 | D 3.625835e-003 [↓ ] | Valid D 1.796666e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 41/124 | D 6.929778e-003 [↑ ] | Valid D 1.872346e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 51/124 | D 1.502809e-003 [↓ ] | Valid D 1.913079e-003 [↑ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 61/124 | D 1.241405e-002 [↑ ] | Valid D 1.924762e-003 [↑ ] | Stag: 30 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 71/124 | D 2.962820e-003 [↓ ] | Valid D 2.024504e-003 [↑ ] | Stag: 40 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 81/124 | D 1.421725e-003 [↓ ] | Valid D 1.919308e-003 [↓ ] | Stag: 50 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 91/124 | D 3.717377e-003 [↑ ] | Valid D 1.854433e-003 [↓ ] | Stag: 60 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 101/124 | D 1.973184e-003 [↓ ] | Valid D 1.907719e-003 [↑ ] | Stag: 70 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 111/124 | D 1.190252e-002 [↑ ] | Valid D 1.867085e-003 [↓ ] | Stag: 80 Ovfit: 0
[12/11/2015 20:21:15] 7/10 | Batch 121/124 | D 2.006255e-003 [↓ ] | Valid D 1.894716e-003 [↑ ] | Stag: 90 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 1/124 | D 1.721533e-003 [↓ ] | Valid D 1.898627e-003 [↑ ] | Stag:100 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 11/124 | D 1.553262e-003 [↓ ] | Valid D 1.897926e-003 [↓ ] | Stag:110 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 21/124 | D 5.004487e-003 [↑ ] | Valid D 1.823838e-003 [↓ ] | Stag:120 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 31/124 | D 3.308986e-003 [↓ ] | Valid D 1.768821e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 41/124 | D 6.563510e-003 [↑ ] | Valid D 1.835302e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 51/124 | D 1.507999e-003 [↓ ] | Valid D 1.868091e-003 [↑ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:15] 8/10 | Batch 61/124 | D 1.148601e-002 [↑ ] | Valid D 1.876653e-003 [↑ ] | Stag: 30 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 71/124 | D 2.807777e-003 [↓ ] | Valid D 1.968064e-003 [↑ ] | Stag: 40 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 81/124 | D 1.440011e-003 [↓ ] | Valid D 1.876611e-003 [↓ ] | Stag: 50 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 91/124 | D 3.522004e-003 [↑ ] | Valid D 1.821817e-003 [↓ ] | Stag: 60 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 101/124 | D 2.031282e-003 [↓ ] | Valid D 1.872902e-003 [↑ ] | Stag: 70 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 111/124 | D 1.182362e-002 [↑ ] | Valid D 1.836957e-003 [↓ ] | Stag: 80 Ovfit: 0
[12/11/2015 20:21:16] 8/10 | Batch 121/124 | D 2.035742e-003 [↓ ] | Valid D 1.864137e-003 [↑ ] | Stag: 90 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 1/124 | D 1.699795e-003 [↓ ] | Valid D 1.865989e-003 [↑ ] | Stag:100 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 11/124 | D 1.556397e-003 [↓ ] | Valid D 1.866347e-003 [↑ ] | Stag:110 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 21/124 | D 4.788828e-003 [↑ ] | Valid D 1.804229e-003 [↓ ] | Stag:120 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 31/124 | D 3.119682e-003 [↓ ] | Valid D 1.756223e-003 [↓▼] | Stag: 0 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 41/124 | D 6.336636e-003 [↑ ] | Valid D 1.816257e-003 [↑ ] | Stag: 10 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 51/124 | D 1.516153e-003 [↓ ] | Valid D 1.843593e-003 [↑ ] | Stag: 20 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 61/124 | D 1.080968e-002 [↑ ] | Valid D 1.850113e-003 [↑ ] | Stag: 30 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 71/124 | D 2.720124e-003 [↓ ] | Valid D 1.934669e-003 [↑ ] | Stag: 40 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 81/124 | D 1.455176e-003 [↓ ] | Valid D 1.852409e-003 [↓ ] | Stag: 50 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 91/124 | D 3.375944e-003 [↑ ] | Valid D 1.804057e-003 [↓ ] | Stag: 60 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 101/124 | D 2.093168e-003 [↓ ] | Valid D 1.853583e-003 [↑ ] | Stag: 70 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 111/124 | D 1.178356e-002 [↑ ] | Valid D 1.820183e-003 [↓ ] | Stag: 80 Ovfit: 0
[12/11/2015 20:21:16] 9/10 | Batch 121/124 | D 2.061530e-003 [↓ ] | Valid D 1.846045e-003 [↑ ] | Stag: 90 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 1/124 | D 1.689459e-003 [↓ ] | Valid D 1.846794e-003 [↑ ] | Stag:100 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 11/124 | D 1.560583e-003 [↓ ] | Valid D 1.847311e-003 [↑ ] | Stag:110 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 21/124 | D 4.588457e-003 [↑ ] | Valid D 1.792883e-003 [↓ ] | Stag:120 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 31/124 | D 3.001853e-003 [↓ ] | Valid D 1.750141e-003 [↓ ] | Stag:130 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 41/124 | D 6.195725e-003 [↑ ] | Valid D 1.805622e-003 [↑ ] | Stag:140 Ovfit: 0
[12/11/2015 20:21:16] 10/10 | Batch 51/124 | D 1.524289e-003 [↓ ] | Valid D 1.829196e-003 [↑ ] | Stag:150 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 61/124 | D 1.029841e-002 [↑ ] | Valid D 1.834366e-003 [↑ ] | Stag:160 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 71/124 | D 2.667856e-003 [↓ ] | Valid D 1.913492e-003 [↑ ] | Stag:170 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 81/124 | D 1.467351e-003 [↓ ] | Valid D 1.837669e-003 [↓ ] | Stag:180 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 91/124 | D 3.261143e-003 [↑ ] | Valid D 1.793646e-003 [↓ ] | Stag:190 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 101/124 | D 2.153974e-003 [↓ ] | Valid D 1.842048e-003 [↑ ] | Stag:200 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 111/124 | D 1.176465e-002 [↑ ] | Valid D 1.810117e-003 [↓ ] | Stag:210 Ovfit: 0
[12/11/2015 20:21:17] 10/10 | Batch 121/124 | D 2.082179e-003 [↓ ] | Valid D 1.834467e-003 [↑ ] | Stag:220 Ovfit: 0
[12/11/2015 20:21:17] Duration : 00:00:05.2093910
[12/11/2015 20:21:17] Loss initial : D 4.748471e-001
[12/11/2015 20:21:17] Loss final : D 1.395002e-003 (Best)
[12/11/2015 20:21:17] Loss change : D -4.734521e-001 (-99.71 %)
[12/11/2015 20:21:17] Loss chg. / s : D -9.088434e-002
[12/11/2015 20:21:17] Epochs / s : 1.919610181
[12/11/2015 20:21:17] Epochs / min : 115.1766109
[12/11/2015 20:21:17] --- Training finished
After a 5-second training, we can see that the characteristics of the problem domain (distinguishing between the digits of 0 and 1) is captured in the model weights.
1:
2:
|
let l = (n.[0] :?> Linear)
l.VisualizeWRowsAsImageGrid(28) |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
|
Hype.Neural.Linear
784 -> 1
Learnable parameters: 785
Init: Standard
W's rows reshaped to (28 x 28), presented in a (1 x 1) grid:
DM : 28 x 28
----------------------------
----------------------------
------------▴▴▴▴▴-----------
---------▴--▴▴▴▴▴▴-▴--------
--------▴▴▪▴▪▪▪▴-▴▴▴▪▪▪▴----
------▴-▴▴▴▴▪▪▴▴-·-▴▪▪▪▪▴---
------▴--▴▴-▴▴--···▴▪▴▴▴▴---
----▴---------▴▴-· ---------
---------··---▴▪--·-·····---
-------······▴▪▪▪▴-······---
------····· ▴●●●▴· ·---
-----·· · ▪♦■♦▪ ·---
-----· · ●■■♦▴ ·---
-----· ·♦██♦· ·---
-----· ▴■██● ·---
----· ▪██■▪ ·---
----· -●█■♦- ·---
----· ▴♦█■●· ···---
----· ·▴♦♦♦●· ····----
----· ·▴▪●●●▪·· ····--▴--
----······-▴▪▪▪▴--------▴---
-----▴▴----·--▴▴-▴▴-▴▴------
-----▴▪▪▴-· ··--▴▴▪▴▴▴▴-----
----▴▪▪▪▪▴-· ·-▴▴▪▴▴▴▴------
-----▴▪▴▴▴▴·---▴▴▴▴▴--------
------------▴▴▴▴------------
----------------------------
----------------------------
b:
DV : 1
|
Classifier
You can create classifiers by instantiating types such as LogisticClassifier or SoftmaxClassifier, and passing a classification function of the form DM->DMin the constructor. Alternatively, you can directly pass the model we have just trained.
Please see the API reference and the source code for a better understanding of how classifiers are implemented.
1:
|
let cc = LogisticClassifier(n)
|
Let's test the class predictions for 10 random elements from the MNIST test set, which, if you remember, we've filtered to have only 0s and 1s.
1:
2:
|
let pred = cc.Classify(MNISTtest01.X.[*,0..9]);;
let real = MNISTtest01.Y.[*, 0..9] |> DM.toDV |> DV.toArray |> Array.map (float32>>int)
|
val pred : int [] = [|1; 0; 1; 0; 1; 0; 0; 1; 1; 1|]
val real : int [] = [|1; 0; 1; 0; 1; 0; 0; 1; 1; 1|]
The classifier seems to be working well. We can compute the classification error for a given dataset.
1:
|
let error = cc.ClassificationError(MNISTtest01);;
|
val error : float32 = 0.000472813234f
The classification error is 0.047%.
Finally, this is how you would classify single digits.
1:
2:
|
let cls = cc.Classify(MNISTtest01.X.[*,0]);;
MNISTtest01.X.[*,0] |> DV.visualizeAsDM 28 |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
|
val cls : int = 1
DM : 28 x 28
♦
●♦
█
■·
▪█-
▴█-
■♦
♦█·
-█▪
█▪
●▪
▪█
▪█-
▪█▴
▪█■
█■
██
▪█
█▴
█●
|
And this is how you would classify many digits efficiently at the same time, by running them through the model together as the columns of an input matrix.
1:
2:
|
let clss = cc.Classify(MNISTtest01.X.[*,5..9]);;
MNISTtest01.[5..9].VisualizeXColsAsImageGrid(28) |> printfn "%s"
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
|
val clss : int [] = [|0; 0; 1; 1; 1|]
Hype.Dataset
X: 784 x 5
Y: 1 x 5
X's columns reshaped to (28 x 28), presented in a (2 x 3) grid:
DM : 56 x 84
██·
●███♦- ·████♦· -█▴
██████■- ♦███████- ▪██·
●███████■ ♦███████████▴ ●██·
▪███● -███- ♦█████████████■ ▴♦█·
♦██▪ -██■ ████♦ ●●████████ ▪█·
▪███ ·██■ ●█████· ··██████ ▪█·
■██▪ ·██■ ▪██████· ██████ ▪█·
·██■ ▪██■ -██████♦ ██████ ▪█·
♦██▪ ■██■ ▪███████ ·█████♦ ●█·
·███- ■██■ ██████♦· ♦██████· ██·
♦██■ ·███■ ██████- ▪███████- ██·
■██- -███- ██████ ●███████▴ ██·
■██· ■██♦ ██████·♦████████■ ██·
■██· ■███● ████████████████ ██
■██● ████ ██████████████- ██
▴███· -■███- ▴████████████▴ ·██
·█████████♦ ■████████■● ██
▴███████♦ ████████ ·█♦·
▪███♦· ●●■●●- ·██▴
█■
·██
███ -██■
●██■ ▪████-
♦██ ♦███■
·███ ·████■
■██♦ ▴███■
▪██■ -████●
███- ▴████▪
▪██■ ·████♦
-███▴ █████·
♦██● ████♦
-███ ▪████·
███▴ ■███■
-███ ▴████·
███● ■███■
████ ■███▪
●███- -███♦
▴███● ●███▪
●██♦ ████▪
●██· ■███▴
■■-
|
val fsi : Compiler.Interactive.InteractiveSession
Full name: Microsoft.FSharp.Compiler.Interactive.Settings.fsi
property Compiler.Interactive.InteractiveSession.ShowDeclarationValues: bool
namespace Hype
namespace Hype.Neural
namespace DiffSharp
namespace DiffSharp.AD
module Float32
from DiffSharp.AD
module Util
from DiffSharp
val MNIST : Dataset
Full name: Regression.MNIST
Multiple items
type Dataset =
new : s:seq<DV * DV> -> Dataset
new : xi:seq<int> * y:DM -> Dataset
new : x:DM * yi:seq<int> -> Dataset
new : xi:seq<int> * yi:seq<int> -> Dataset
new : x:DM * y:DM -> Dataset
new : xi:seq<int> * onehotdimsx:int * y:DM -> Dataset
new : x:DM * yi:seq<int> * onehotdimsy:int -> Dataset
new : xi:seq<int> * onehotdimsx:int * yi:seq<int> * onehotdimsy:int -> Dataset
private new : x:DM * y:DM * xi:seq<int> * yi:seq<int> -> Dataset
member AppendBiasRowX : unit -> Dataset
...
Full name: Hype.Dataset
--------------------
new : s:seq<DV * DV> -> Dataset
new : x:DM * y:DM -> Dataset
new : xi:seq<int> * yi:seq<int> -> Dataset
new : x:DM * yi:seq<int> -> Dataset
new : xi:seq<int> * y:DM -> Dataset
new : x:DM * yi:seq<int> * onehotdimsy:int -> Dataset
new : xi:seq<int> * onehotdimsx:int * y:DM -> Dataset
new : xi:seq<int> * onehotdimsx:int * yi:seq<int> * onehotdimsy:int -> Dataset
type Util =
static member LoadDelimited : filename:string -> DM
static member LoadDelimited : filename:string * separators:char [] -> DM
static member LoadImage : filename:string -> DM
static member LoadMNISTLabels : filename:string -> int []
static member LoadMNISTLabels : filename:string * n:int -> int []
static member LoadMNISTPixels : filename:string -> DM
static member LoadMNISTPixels : filename:string * n:int -> DM
static member VisualizeDMRowsAsImageGrid : w:DM * imagerows:int -> string
static member printLog : s:string -> unit
static member printModel : f:(DV -> DV) -> d:Dataset -> unit
Full name: Hype.Util
static member Util.LoadMNISTPixels : filename:string -> DM
static member Util.LoadMNISTPixels : filename:string * n:int -> DM
static member Util.LoadMNISTLabels : filename:string -> int []
static member Util.LoadMNISTLabels : filename:string * n:int -> int []
val toDV : v:seq<'a> -> DV (requires member op_Explicit)
Full name: DiffSharp.AD.Float32.DOps.toDV
Multiple items
union case DM.DM: float32 [,] -> DM
--------------------
module DM
from DiffSharp.AD.Float32
--------------------
type DM =
| DM of float32 [,]
| DMF of DM * DM * uint32
| DMR of DM * DM ref * TraceOp * uint32 ref * uint32
member Copy : unit -> DM
member GetCols : unit -> seq<DV>
member GetForward : t:DM * i:uint32 -> DM
member GetReverse : i:uint32 -> DM
member GetRows : unit -> seq<DV>
member GetSlice : rowStart:int option * rowFinish:int option * col:int -> DV
member GetSlice : row:int * colStart:int option * colFinish:int option -> DV
member GetSlice : rowStart:int option * rowFinish:int option * colStart:int option * colFinish:int option -> DM
member ToMathematicaString : unit -> string
member ToMatlabString : unit -> string
override ToString : unit -> string
member Visualize : unit -> string
member A : DM
member Cols : int
member F : uint32
member Item : i:int * j:int -> D with get
member Length : int
member P : DM
member PD : DM
member Rows : int
member T : DM
member A : DM with set
member F : uint32 with set
static member Abs : a:DM -> DM
static member Acos : a:DM -> DM
static member AddDiagonal : a:DM * b:DV -> DM
static member AddItem : a:DM * i:int * j:int * b:D -> DM
static member AddSubMatrix : a:DM * i:int * j:int * b:DM -> DM
static member Asin : a:DM -> DM
static member Atan : a:DM -> DM
static member Atan2 : a:int * b:DM -> DM
static member Atan2 : a:DM * b:int -> DM
static member Atan2 : a:float32 * b:DM -> DM
static member Atan2 : a:DM * b:float32 -> DM
static member Atan2 : a:D * b:DM -> DM
static member Atan2 : a:DM * b:D -> DM
static member Atan2 : a:DM * b:DM -> DM
static member Ceiling : a:DM -> DM
static member Cos : a:DM -> DM
static member Cosh : a:DM -> DM
static member Det : a:DM -> D
static member Diagonal : a:DM -> DV
static member Exp : a:DM -> DM
static member Floor : a:DM -> DM
static member Inverse : a:DM -> DM
static member Log : a:DM -> DM
static member Log10 : a:DM -> DM
static member Max : a:DM -> D
static member Max : a:D * b:DM -> DM
static member Max : a:DM * b:D -> DM
static member Max : a:DM * b:DM -> DM
static member MaxIndex : a:DM -> int * int
static member Mean : a:DM -> D
static member Min : a:DM -> D
static member Min : a:D * b:DM -> DM
static member Min : a:DM * b:D -> DM
static member Min : a:DM * b:DM -> DM
static member MinIndex : a:DM -> int * int
static member Normalize : a:DM -> DM
static member OfArray : m:int * a:D [] -> DM
static member OfArray2D : a:D [,] -> DM
static member OfCols : n:int * a:DV -> DM
static member OfRows : s:seq<DV> -> DM
static member OfRows : m:int * a:DV -> DM
static member Op_DM_D : a:DM * ff:(float32 [,] -> float32) * fd:(DM -> D) * df:(D * DM * DM -> D) * r:(DM -> TraceOp) -> D
static member Op_DM_DM : a:DM * ff:(float32 [,] -> float32 [,]) * fd:(DM -> DM) * df:(DM * DM * DM -> DM) * r:(DM -> TraceOp) -> DM
static member Op_DM_DM_DM : a:DM * b:DM * ff:(float32 [,] * float32 [,] -> float32 [,]) * fd:(DM * DM -> DM) * df_da:(DM * DM * DM -> DM) * df_db:(DM * DM * DM -> DM) * df_dab:(DM * DM * DM * DM * DM -> DM) * r_d_d:(DM * DM -> TraceOp) * r_d_c:(DM * DM -> TraceOp) * r_c_d:(DM * DM -> TraceOp) -> DM
static member Op_DM_DV : a:DM * ff:(float32 [,] -> float32 []) * fd:(DM -> DV) * df:(DV * DM * DM -> DV) * r:(DM -> TraceOp) -> DV
static member Op_DM_DV_DM : a:DM * b:DV * ff:(float32 [,] * float32 [] -> float32 [,]) * fd:(DM * DV -> DM) * df_da:(DM * DM * DM -> DM) * df_db:(DM * DV * DV -> DM) * df_dab:(DM * DM * DM * DV * DV -> DM) * r_d_d:(DM * DV -> TraceOp) * r_d_c:(DM * DV -> TraceOp) * r_c_d:(DM * DV -> TraceOp) -> DM
static member Op_DM_DV_DV : a:DM * b:DV * ff:(float32 [,] * float32 [] -> float32 []) * fd:(DM * DV -> DV) * df_da:(DV * DM * DM -> DV) * df_db:(DV * DV * DV -> DV) * df_dab:(DV * DM * DM * DV * DV -> DV) * r_d_d:(DM * DV -> TraceOp) * r_d_c:(DM * DV -> TraceOp) * r_c_d:(DM * DV -> TraceOp) -> DV
static member Op_DM_D_DM : a:DM * b:D * ff:(float32 [,] * float32 -> float32 [,]) * fd:(DM * D -> DM) * df_da:(DM * DM * DM -> DM) * df_db:(DM * D * D -> DM) * df_dab:(DM * DM * DM * D * D -> DM) * r_d_d:(DM * D -> TraceOp) * r_d_c:(DM * D -> TraceOp) * r_c_d:(DM * D -> TraceOp) -> DM
static member Op_DV_DM_DM : a:DV * b:DM * ff:(float32 [] * float32 [,] -> float32 [,]) * fd:(DV * DM -> DM) * df_da:(DM * DV * DV -> DM) * df_db:(DM * DM * DM -> DM) * df_dab:(DM * DV * DV * DM * DM -> DM) * r_d_d:(DV * DM -> TraceOp) * r_d_c:(DV * DM -> TraceOp) * r_c_d:(DV * DM -> TraceOp) -> DM
static member Op_DV_DM_DV : a:DV * b:DM * ff:(float32 [] * float32 [,] -> float32 []) * fd:(DV * DM -> DV) * df_da:(DV * DV * DV -> DV) * df_db:(DV * DM * DM -> DV) * df_dab:(DV * DV * DV * DM * DM -> DV) * r_d_d:(DV * DM -> TraceOp) * r_d_c:(DV * DM -> TraceOp) * r_c_d:(DV * DM -> TraceOp) -> DV
static member Op_D_DM_DM : a:D * b:DM * ff:(float32 * float32 [,] -> float32 [,]) * fd:(D * DM -> DM) * df_da:(DM * D * D -> DM) * df_db:(DM * DM * DM -> DM) * df_dab:(DM * D * D * DM * DM -> DM) * r_d_d:(D * DM -> TraceOp) * r_d_c:(D * DM -> TraceOp) * r_c_d:(D * DM -> TraceOp) -> DM
static member Pow : a:int * b:DM -> DM
static member Pow : a:DM * b:int -> DM
static member Pow : a:float32 * b:DM -> DM
static member Pow : a:DM * b:float32 -> DM
static member Pow : a:D * b:DM -> DM
static member Pow : a:DM * b:D -> DM
static member Pow : a:DM * b:DM -> DM
static member ReLU : a:DM -> DM
static member ReshapeToDV : a:DM -> DV
static member Round : a:DM -> DM
static member Sigmoid : a:DM -> DM
static member Sign : a:DM -> DM
static member Sin : a:DM -> DM
static member Sinh : a:DM -> DM
static member SoftPlus : a:DM -> DM
static member SoftSign : a:DM -> DM
static member Solve : a:DM * b:DV -> DV
static member SolveSymmetric : a:DM * b:DV -> DV
static member Sqrt : a:DM -> DM
static member StandardDev : a:DM -> D
static member Standardize : a:DM -> DM
static member Sum : a:DM -> D
static member Tan : a:DM -> DM
static member Tanh : a:DM -> DM
static member Trace : a:DM -> D
static member Transpose : a:DM -> DM
static member Variance : a:DM -> D
static member ZeroMN : m:int -> n:int -> DM
static member Zero : DM
static member ( + ) : a:int * b:DM -> DM
static member ( + ) : a:DM * b:int -> DM
static member ( + ) : a:float32 * b:DM -> DM
static member ( + ) : a:DM * b:float32 -> DM
static member ( + ) : a:DM * b:DV -> DM
static member ( + ) : a:DV * b:DM -> DM
static member ( + ) : a:D * b:DM -> DM
static member ( + ) : a:DM * b:D -> DM
static member ( + ) : a:DM * b:DM -> DM
static member ( / ) : a:int * b:DM -> DM
static member ( / ) : a:DM * b:int -> DM
static member ( / ) : a:float32 * b:DM -> DM
static member ( / ) : a:DM * b:float32 -> DM
static member ( / ) : a:D * b:DM -> DM
static member ( / ) : a:DM * b:D -> DM
static member ( ./ ) : a:DM * b:DM -> DM
static member ( .* ) : a:DM * b:DM -> DM
static member op_Explicit : d:float32 [,] -> DM
static member op_Explicit : d:DM -> float32 [,]
static member ( * ) : a:int * b:DM -> DM
static member ( * ) : a:DM * b:int -> DM
static member ( * ) : a:float32 * b:DM -> DM
static member ( * ) : a:DM * b:float32 -> DM
static member ( * ) : a:D * b:DM -> DM
static member ( * ) : a:DM * b:D -> DM
static member ( * ) : a:DV * b:DM -> DV
static member ( * ) : a:DM * b:DV -> DV
static member ( * ) : a:DM * b:DM -> DM
static member ( - ) : a:int * b:DM -> DM
static member ( - ) : a:DM * b:int -> DM
static member ( - ) : a:float32 * b:DM -> DM
static member ( - ) : a:DM * b:float32 -> DM
static member ( - ) : a:D * b:DM -> DM
static member ( - ) : a:DM * b:D -> DM
static member ( - ) : a:DM * b:DM -> DM
static member ( ~- ) : a:DM -> DM
Full name: DiffSharp.AD.Float32.DM
val ofDV : m:int -> v:DV -> DM
Full name: DiffSharp.AD.Float32.DM.ofDV
val MNISTtrain : Dataset
Full name: Regression.MNISTtrain
val MNISTvalid : Dataset
Full name: Regression.MNISTvalid
val MNISTtest : Dataset
Full name: Regression.MNISTtest
val MNISTtrain01 : Dataset
Full name: Regression.MNISTtrain01
member Dataset.Shuffle : unit -> Dataset
val x : DV
val y : DV
union case D.D: float32 -> D
val MNISTvalid01 : Dataset
Full name: Regression.MNISTvalid01
val MNISTtest01 : Dataset
Full name: Regression.MNISTtest01
property Dataset.X: DM
Multiple items
union case DV.DV: float32 [] -> DV
--------------------
module DV
from DiffSharp.AD.Float32
--------------------
type DV =
| DV of float32 []
| DVF of DV * DV * uint32
| DVR of DV * DV ref * TraceOp * uint32 ref * uint32
member Copy : unit -> DV
member GetForward : t:DV * i:uint32 -> DV
member GetReverse : i:uint32 -> DV
member GetSlice : lower:int option * upper:int option -> DV
member ToArray : unit -> D []
member ToColDM : unit -> DM
member ToMathematicaString : unit -> string
member ToMatlabString : unit -> string
member ToRowDM : unit -> DM
override ToString : unit -> string
member Visualize : unit -> string
member A : DV
member F : uint32
member Item : i:int -> D with get
member Length : int
member P : DV
member PD : DV
member T : DV
member A : DV with set
member F : uint32 with set
static member Abs : a:DV -> DV
static member Acos : a:DV -> DV
static member AddItem : a:DV * i:int * b:D -> DV
static member AddSubVector : a:DV * i:int * b:DV -> DV
static member Append : a:DV * b:DV -> DV
static member Asin : a:DV -> DV
static member Atan : a:DV -> DV
static member Atan2 : a:int * b:DV -> DV
static member Atan2 : a:DV * b:int -> DV
static member Atan2 : a:float32 * b:DV -> DV
static member Atan2 : a:DV * b:float32 -> DV
static member Atan2 : a:D * b:DV -> DV
static member Atan2 : a:DV * b:D -> DV
static member Atan2 : a:DV * b:DV -> DV
static member Ceiling : a:DV -> DV
static member Cos : a:DV -> DV
static member Cosh : a:DV -> DV
static member Exp : a:DV -> DV
static member Floor : a:DV -> DV
static member L1Norm : a:DV -> D
static member L2Norm : a:DV -> D
static member L2NormSq : a:DV -> D
static member Log : a:DV -> DV
static member Log10 : a:DV -> DV
static member LogSumExp : a:DV -> D
static member Max : a:DV -> D
static member Max : a:D * b:DV -> DV
static member Max : a:DV * b:D -> DV
static member Max : a:DV * b:DV -> DV
static member MaxIndex : a:DV -> int
static member Mean : a:DV -> D
static member Min : a:DV -> D
static member Min : a:D * b:DV -> DV
static member Min : a:DV * b:D -> DV
static member Min : a:DV * b:DV -> DV
static member MinIndex : a:DV -> int
static member Normalize : a:DV -> DV
static member OfArray : a:D [] -> DV
static member Op_DV_D : a:DV * ff:(float32 [] -> float32) * fd:(DV -> D) * df:(D * DV * DV -> D) * r:(DV -> TraceOp) -> D
static member Op_DV_DM : a:DV * ff:(float32 [] -> float32 [,]) * fd:(DV -> DM) * df:(DM * DV * DV -> DM) * r:(DV -> TraceOp) -> DM
static member Op_DV_DV : a:DV * ff:(float32 [] -> float32 []) * fd:(DV -> DV) * df:(DV * DV * DV -> DV) * r:(DV -> TraceOp) -> DV
static member Op_DV_DV_D : a:DV * b:DV * ff:(float32 [] * float32 [] -> float32) * fd:(DV * DV -> D) * df_da:(D * DV * DV -> D) * df_db:(D * DV * DV -> D) * df_dab:(D * DV * DV * DV * DV -> D) * r_d_d:(DV * DV -> TraceOp) * r_d_c:(DV * DV -> TraceOp) * r_c_d:(DV * DV -> TraceOp) -> D
static member Op_DV_DV_DM : a:DV * b:DV * ff:(float32 [] * float32 [] -> float32 [,]) * fd:(DV * DV -> DM) * df_da:(DM * DV * DV -> DM) * df_db:(DM * DV * DV -> DM) * df_dab:(DM * DV * DV * DV * DV -> DM) * r_d_d:(DV * DV -> TraceOp) * r_d_c:(DV * DV -> TraceOp) * r_c_d:(DV * DV -> TraceOp) -> DM
static member Op_DV_DV_DV : a:DV * b:DV * ff:(float32 [] * float32 [] -> float32 []) * fd:(DV * DV -> DV) * df_da:(DV * DV * DV -> DV) * df_db:(DV * DV * DV -> DV) * df_dab:(DV * DV * DV * DV * DV -> DV) * r_d_d:(DV * DV -> TraceOp) * r_d_c:(DV * DV -> TraceOp) * r_c_d:(DV * DV -> TraceOp) -> DV
static member Op_DV_D_DV : a:DV * b:D * ff:(float32 [] * float32 -> float32 []) * fd:(DV * D -> DV) * df_da:(DV * DV * DV -> DV) * df_db:(DV * D * D -> DV) * df_dab:(DV * DV * DV * D * D -> DV) * r_d_d:(DV * D -> TraceOp) * r_d_c:(DV * D -> TraceOp) * r_c_d:(DV * D -> TraceOp) -> DV
static member Op_D_DV_DV : a:D * b:DV * ff:(float32 * float32 [] -> float32 []) * fd:(D * DV -> DV) * df_da:(DV * D * D -> DV) * df_db:(DV * DV * DV -> DV) * df_dab:(DV * D * D * DV * DV -> DV) * r_d_d:(D * DV -> TraceOp) * r_d_c:(D * DV -> TraceOp) * r_c_d:(D * DV -> TraceOp) -> DV
static member Pow : a:int * b:DV -> DV
static member Pow : a:DV * b:int -> DV
static member Pow : a:float32 * b:DV -> DV
static member Pow : a:DV * b:float32 -> DV
static member Pow : a:D * b:DV -> DV
static member Pow : a:DV * b:D -> DV
static member Pow : a:DV * b:DV -> DV
static member ReLU : a:DV -> DV
static member ReshapeToDM : m:int * a:DV -> DM
static member Round : a:DV -> DV
static member Sigmoid : a:DV -> DV
static member Sign : a:DV -> DV
static member Sin : a:DV -> DV
static member Sinh : a:DV -> DV
static member SoftMax : a:DV -> DV
static member SoftPlus : a:DV -> DV
static member SoftSign : a:DV -> DV
static member Split : d:DV * n:seq<int> -> seq<DV>
static member Sqrt : a:DV -> DV
static member StandardDev : a:DV -> D
static member Standardize : a:DV -> DV
static member Sum : a:DV -> D
static member Tan : a:DV -> DV
static member Tanh : a:DV -> DV
static member Variance : a:DV -> D
static member ZeroN : n:int -> DV
static member Zero : DV
static member ( + ) : a:int * b:DV -> DV
static member ( + ) : a:DV * b:int -> DV
static member ( + ) : a:float32 * b:DV -> DV
static member ( + ) : a:DV * b:float32 -> DV
static member ( + ) : a:D * b:DV -> DV
static member ( + ) : a:DV * b:D -> DV
static member ( + ) : a:DV * b:DV -> DV
static member ( &* ) : a:DV * b:DV -> DM
static member ( / ) : a:int * b:DV -> DV
static member ( / ) : a:DV * b:int -> DV
static member ( / ) : a:float32 * b:DV -> DV
static member ( / ) : a:DV * b:float32 -> DV
static member ( / ) : a:D * b:DV -> DV
static member ( / ) : a:DV * b:D -> DV
static member ( ./ ) : a:DV * b:DV -> DV
static member ( .* ) : a:DV * b:DV -> DV
static member op_Explicit : d:float32 [] -> DV
static member op_Explicit : d:DV -> float32 []
static member ( * ) : a:int * b:DV -> DV
static member ( * ) : a:DV * b:int -> DV
static member ( * ) : a:float32 * b:DV -> DV
static member ( * ) : a:DV * b:float32 -> DV
static member ( * ) : a:D * b:DV -> DV
static member ( * ) : a:DV * b:D -> DV
static member ( * ) : a:DV * b:DV -> D
static member ( - ) : a:int * b:DV -> DV
static member ( - ) : a:DV * b:int -> DV
static member ( - ) : a:float32 * b:DV -> DV
static member ( - ) : a:DV * b:float32 -> DV
static member ( - ) : a:D * b:DV -> DV
static member ( - ) : a:DV * b:D -> DV
static member ( - ) : a:DV * b:DV -> DV
static member ( ~- ) : a:DV -> DV
Full name: DiffSharp.AD.Float32.DV
val visualizeAsDM : m:int -> v:DV -> string
Full name: DiffSharp.AD.Float32.DV.visualizeAsDM
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
property Dataset.Y: DM
val n : FeedForward
Full name: Regression.n
Multiple items
type FeedForward =
inherit Layer
new : unit -> FeedForward
member Add : f:(DM -> DM) -> unit
member Add : l:Layer -> unit
override Decode : w:DV -> unit
override Encode : unit -> DV
override Init : unit -> unit
member Insert : i:int * f:(DM -> DM) -> unit
member Insert : i:int * l:Layer -> unit
member Remove : i:int -> unit
...
Full name: Hype.Neural.FeedForward
--------------------
new : unit -> FeedForward
member FeedForward.Add : f:(DM -> DM) -> unit
member FeedForward.Add : l:Layer -> unit
Multiple items
type Linear =
inherit Layer
new : inputs:int * outputs:int -> Linear
new : inputs:int * outputs:int * initializer:Initializer -> Linear
override Decode : w:DV -> unit
override Encode : unit -> DV
override Init : unit -> unit
override Reset : unit -> unit
override Run : x:DM -> DM
override ToString : unit -> string
override ToStringFull : unit -> string
...
Full name: Hype.Neural.Linear
--------------------
new : inputs:int * outputs:int -> Linear
new : inputs:int * outputs:int * initializer:Initializer -> Linear
val sigmoid : x:'a -> 'a (requires member Sigmoid)
Full name: DiffSharp.Util.sigmoid
val l : Linear
Full name: Regression.l
member Linear.VisualizeWRowsAsImageGrid : imagerows:int -> string
val p : Params
Full name: Regression.p
Multiple items
module Params
from Hype
--------------------
type Params =
{Epochs: int;
Method: Method;
LearningRate: LearningRate;
Momentum: Momentum;
Loss: Loss;
Regularization: Regularization;
GradientClipping: GradientClipping;
Batch: Batch;
EarlyStopping: EarlyStopping;
ImprovementThreshold: D;
...}
Full name: Hype.Params
val Default : Params
Full name: Hype.Params.Default
type Batch =
| Full
| Minibatch of int
| Stochastic
override ToString : unit -> string
member Func : (Dataset -> int -> Dataset)
Full name: Hype.Batch
union case Batch.Minibatch: int -> Batch
type EarlyStopping =
| Early of int * int
| NoEarly
override ToString : unit -> string
static member DefaultEarly : EarlyStopping
Full name: Hype.EarlyStopping
property EarlyStopping.DefaultEarly: EarlyStopping
member Layer.Train : d:Dataset -> D * D []
member Layer.Train : d:Dataset * par:Params -> D * D []
member Layer.Train : d:Dataset * v:Dataset -> D * D []
member Layer.Train : d:Dataset * v:Dataset * par:Params -> D * D []
val cc : LogisticClassifier
Full name: Regression.cc
Multiple items
type LogisticClassifier =
inherit Classifier
new : l:Layer -> LogisticClassifier
new : f:(DM -> DM) -> LogisticClassifier
override Classify : x:DV -> int
override Classify : x:DM -> int []
Full name: Hype.LogisticClassifier
--------------------
new : f:(DM -> DM) -> LogisticClassifier
new : l:Layer -> LogisticClassifier
val pred : int []
Full name: Regression.pred
override LogisticClassifier.Classify : x:DV -> int
override LogisticClassifier.Classify : x:DM -> int []
val real : int []
Full name: Regression.real
val toDV : m:DM -> DV
Full name: DiffSharp.AD.Float32.DM.toDV
val toArray : v:DV -> D []
Full name: DiffSharp.AD.Float32.DV.toArray
Multiple items
module Array
from DiffSharp.Util
--------------------
module Array
from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
Full name: Microsoft.FSharp.Collections.Array.map
Multiple items
val float32 : value:'T -> float32 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.float32
--------------------
type float32 = System.Single
Full name: Microsoft.FSharp.Core.float32
--------------------
type float32<'Measure> = float32
Full name: Microsoft.FSharp.Core.float32<_>
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val error : float32
Full name: Regression.error
member Classifier.ClassificationError : d:Dataset -> float32
member Classifier.ClassificationError : x:DM * y:int [] -> float32
val cls : int
Full name: Regression.cls
val clss : int []
Full name: Regression.clss