@@ -127,7 +127,7 @@ describe('GPT Layers', function () {
127
127
// MLP Layer tests
128
128
describe ( 'MLP Layer' , function ( ) {
129
129
130
- it ( 'should produce deterministic outputs with the same random seed' , async function ( ) {
130
+ it ( 'should produce deterministic/non-NaN outputs with the same random seed' , async function ( ) {
131
131
// an MLP config with a fixed seed
132
132
const config : MLPConfig = {
133
133
name : 'testMLP' ,
@@ -142,8 +142,6 @@ describe('GPT Layers', function () {
142
142
// two separate MLP model instances using the same config
143
143
const model1 = MLP ( config ) ;
144
144
const model2 = MLP ( config ) ;
145
-
146
- //TODO: check if there are NANs
147
145
148
146
const input = tf . ones ( [ 1 , config . contextLength , config . nEmbd ] ) ;
149
147
@@ -159,7 +157,15 @@ describe('GPT Layers', function () {
159
157
160
158
// check that the models produce the same output
161
159
expect ( arr1 ) . to . deep . equal ( arr2 ) ;
162
-
160
+
161
+ // Check that there are no NaN values in the outputs.
162
+ for ( let i = 0 ; i < arr1 . length ; i ++ ) {
163
+ expect ( isNaN ( arr1 [ i ] ) ) . to . be . false ;
164
+ }
165
+ for ( let i = 0 ; i < arr2 . length ; i ++ ) {
166
+ expect ( isNaN ( arr2 [ i ] ) ) . to . be . false ;
167
+ }
168
+
163
169
} ) ;
164
170
} ) ;
165
171
0 commit comments