You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert(net._prepTraining.calledOnce,`_prepTraining was expected to be called once but was called ${net._prepTraining.callCount}`);
96
+
net
97
+
.trainAsync(trainingData,opts)
98
+
.then(()=>{
99
+
assert(net._prepTraining.calledTwice,`_prepTraining was expected to be called twice but was called ${net._prepTraining.callCount}`);
85
100
done();
86
101
})
87
-
.catch(err=>{assert.ok(false,err.toString())});
88
-
}).timeout(10000);
102
+
.catch(e=>{
103
+
assert.ok(false,e.toString());
104
+
done()
105
+
});
106
+
});
89
107
90
-
it('train until max iterations reached',(done)=>{
91
-
letnet=newbrain.NeuralNetwork();
92
-
letres=net
93
-
.trainAsync(data,{iterations: 25})
94
-
.then(res=>{
95
-
assert.equal(res.iterations,25,`[res.iterations, ${res.iterations}] should have been less then 25`);
108
+
it('_updateTrainingOptions()',(done)=>{
109
+
net.train(trainingData,opts);
110
+
assert(net._updateTrainingOptions.calledOnce,`_updateTrainingOptions was expected to be called once but was called ${net._updateTrainingOptions.callCount}`);
111
+
net
112
+
.trainAsync(trainingData,opts)
113
+
.then(()=>{
114
+
assert(net._updateTrainingOptions.calledTwice,`_updateTrainingOptions was expected to be called twice but was called ${net._prepTraining.callCount}`);
96
115
done();
97
116
})
98
-
.catch(err=>{assert.ok(false,err.toString())});
99
-
}).timeout(10000);
100
-
101
-
it('asyinc training callback called with training stats',(done)=>{
102
-
letiters=100;
103
-
letperiod=20;
104
-
lettarget=iters/period;
105
-
106
-
letcalls=0;
107
-
108
-
letnet=newbrain.NeuralNetwork();
109
-
net.trainAsync(data,{
110
-
iterations: iters,
111
-
callbackPeriod: period,
112
-
callback: (res)=>{
113
-
assert.ok(res.iterations%period==0);
114
-
calls++;
115
-
}
116
-
})
117
-
.then(res=>{
118
-
assert.ok(target===calls,`[calls, ${calls}] should be the same as [target, ${target}]`);
119
-
done();
120
-
})
121
-
.catch(err=>{assert.ok(false,err.toString())});
122
-
}).timeout(10000);
123
-
124
-
it('learningRate ASYNC - higher learning rate should train faster',(done)=>{
assert(net._formatData.calledOnce,`_formatData was expected to be called once but was called ${net._formatData.callCount}`);
126
+
net
127
+
.trainAsync(trainingData,opts)
128
+
.then(()=>{
129
+
assert(net._formatData.calledTwice,`_formatData was expected to be called twice but was called ${net._prepTraining.callCount}`);
144
130
done();
145
131
})
146
-
.catch(err=>{
147
-
assert.ok(false,err.toString())
132
+
.catch(e=>{
133
+
assert.ok(false,e.toString());
134
+
done()
148
135
});
149
-
}).timeout(10000);
150
-
151
-
it('momentum ASYNC - higher momentum should train faster',(done)=>{
152
-
letdata=[
153
-
{input: [0,0],output: [0]},
154
-
{input: [0,1],output: [1]},
155
-
{input: [1,0],output: [1]},
156
-
{input: [1,1],output: [1]}
157
-
];
158
-
159
-
letnet=newbrain.NeuralNetwork({momentum: 0.1});
160
-
letnet2=newbrain.NeuralNetwork({momentum: 0.5});
136
+
});
161
137
162
-
letp1=net.trainAsync(data);
163
-
letp2=net2.trainAsync(data);
138
+
it('_verifyIsInitialized()',(done)=>{
139
+
net.train(trainingData,opts);
140
+
assert(net._verifyIsInitialized.calledOnce,`_verifyIsInitialized was expected to be called once but was called ${net._verifyIsInitialized.callCount}`);
141
+
net
142
+
.trainAsync(trainingData,opts)
143
+
.then(()=>{
144
+
assert(net._verifyIsInitialized.calledTwice,`_verifyIsInitialized was expected to be called twice but was called ${net._prepTraining.callCount}`);
0 commit comments