UNPKG

@tensorflow/tfjs-core

Version:

Hardware-accelerated JavaScript library for machine intelligence

41 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tf = require("./index"); var test_util_1 = require("./test_util"); var jasmine_util_1 = require("./jasmine_util"); jasmine_util_1.describeWithFlags('debug on', test_util_1.ALL_ENVS, function () { beforeAll(function () { tf.ENV.set('DEBUG', true); }); afterAll(function () { tf.ENV.set('DEBUG', false); }); it('debug mode does not error when no nans', function () { var a = tf.tensor1d([2, -1, 0, 3]); var res = tf.relu(a); test_util_1.expectArraysClose(res, [2, 0, 0, 3]); }); it('debug mode errors when there are nans, float32', function () { var a = tf.tensor1d([2, NaN]); var f = function () { return tf.relu(a); }; expect(f).toThrowError(); }); it('A x B', function () { var a = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); var b = tf.tensor2d([0, 1, -3, 2, 2, 1], [3, 2]); var c = tf.matMul(a, b); expect(c.shape).toEqual([2, 2]); test_util_1.expectArraysClose(c, [0, 8, -3, 20]); }); }); jasmine_util_1.describeWithFlags('debug off', test_util_1.ALL_ENVS, function () { beforeAll(function () { tf.ENV.set('DEBUG', false); }); it('no errors where there are nans, and debug mode is disabled', function () { var a = tf.tensor1d([2, NaN]); var res = tf.relu(a); test_util_1.expectArraysClose(res, [2, NaN]); }); }); //# sourceMappingURL=debug_mode_test.js.map