ml5
Version:
A friendly machine learning library for the web.
18 lines • 2.67 MB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ml5=e():t.ml5=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=968)}([function(t,e,n){"use strict";n.r(e),function(t,r,i,o){n.d(e,"AdadeltaOptimizer",function(){return Mf}),n.d(e,"AdagradOptimizer",function(){return Nf}),n.d(e,"AdamOptimizer",function(){return Tf}),n.d(e,"AdamaxOptimizer",function(){return If}),n.d(e,"DataStorage",function(){return Gr}),n.d(e,"ENV",function(){return h}),n.d(e,"Environment",function(){return f}),n.d(e,"KernelBackend",function(){return Kr}),n.d(e,"MomentumOptimizer",function(){return jf}),n.d(e,"Optimizer",function(){return Cf}),n.d(e,"RMSPropOptimizer",function(){return Rf}),n.d(e,"Rank",function(){return bt}),n.d(e,"Reduction",function(){return Bc}),n.d(e,"SGDOptimizer",function(){return Df}),n.d(e,"Tensor",function(){return gt}),n.d(e,"TensorBuffer",function(){return dt}),n.d(e,"Variable",function(){return vt}),n.d(e,"abs",function(){return Ga}),n.d(e,"acos",function(){return Ka}),n.d(e,"acosh",function(){return Xa}),n.d(e,"add",function(){return Bu}),n.d(e,"addN",function(){return Uu}),n.d(e,"addStrict",function(){return Wu}),n.d(e,"all",function(){return vu}),n.d(e,"any",function(){return bu}),n.d(e,"argMax",function(){return yu}),n.d(e,"argMin",function(){return wu}),n.d(e,"asin",function(){return Ya}),n.d(e,"asinh",function(){return Ja}),n.d(e,"atan",function(){return Za}),n.d(e,"atan2",function(){return qu}),n.d(e,"atanh",function(){return Qa}),n.d(e,"avgPool",function(){return cu}),n.d(e,"backend",function(){return Ye}),n.d(e,"backend_util",function(){return fi}),n.d(e,"basicLSTMCell",function(){return Ec}),n.d(e,"batchNorm",function(){return zs}),n.d(e,"batchNorm2d",function(){return Ls}),n.d(e,"batchNorm3d",function(){return Bs}),n.d(e,"batchNorm4d",function(){return Us}),n.d(e,"batchNormalization",function(){return Ps}),n.d(e,"batchNormalization2d",function(){return js}),n.d(e,"batchNormalization3d",function(){return Rs}),n.d(e,"batchNormalization4d",function(){return Fs}),n.d(e,"batchToSpaceND",function(){return Qn}),n.d(e,"browser",function(){return mf}),n.d(e,"buffer",function(){return Jn}),n.d(e,"cast",function(){return tr}),n.d(e,"ceil",function(){return ts}),n.d(e,"clipByValue",function(){return es}),n.d(e,"clone",function(){return er}),n.d(e,"complex",function(){return mn}),n.d(e,"concat",function(){return jn}),n.d(e,"concat1d",function(){return Rn}),n.d(e,"concat2d",function(){return Fn}),n.d(e,"concat3d",function(){return Pn}),n.d(e,"concat4d",function(){return zn}),n.d(e,"conv1d",function(){return Hs}),n.d(e,"conv2d",function(){return $s}),n.d(e,"conv2dDerFilter",function(){return Ks}),n.d(e,"conv2dTranspose",function(){return Js}),n.d(e,"conv3d",function(){return Gs}),n.d(e,"cos",function(){return ns}),n.d(e,"cosh",function(){return rs}),n.d(e,"cumsum",function(){return nr}),n.d(e,"customGrad",function(){return qr}),n.d(e,"deprecationWarn",function(){return Re}),n.d(e,"depthToSpace",function(){return rr}),n.d(e,"depthwiseConv2d",function(){return Xs}),n.d(e,"disableDeprecationWarnings",function(){return je}),n.d(e,"dispose",function(){return Be}),n.d(e,"disposeVariables",function(){return Fe}),n.d(e,"div",function(){return Vu}),n.d(e,"divStrict",function(){return Hu}),n.d(e,"dot",function(){return Qs}),n.d(e,"dropout",function(){return zc}),n.d(e,"elu",function(){return hc}),n.d(e,"enableDebugMode",function(){return De}),n.d(e,"enableProdMode",function(){return Ie}),n.d(e,"environment",function(){return m}),n.d(e,"equal",function(){return Cu}),n.d(e,"equalStrict",function(){return Mu}),n.d(e,"erf",function(){return is}),n.d(e,"exp",function(){return os}),n.d(e,"expandDims",function(){return ir}),n.d(e,"expm1",function(){return as}),n.d(e,"eye",function(){return or}),n.d(e,"fft",function(){return Tc}),n.d(e,"fill",function(){return Mn}),n.d(e,"findBackend",function(){return Ge}),n.d(e,"findBackendFactory",function(){return Ke}),n.d(e,"floor",function(){return ss}),n.d(e,"floorDiv",function(){return $u}),n.d(e,"frame",function(){return qc}),n.d(e,"fused",function(){return dl}),n.d(e,"gather",function(){return kc}),n.d(e,"gatherND",function(){return Pc}),n.d(e,"getBackend",function(){return He}),n.d(e,"grad",function(){return zr}),n.d(e,"grads",function(){return Lr}),n.d(e,"greater",function(){return Nu}),n.d(e,"greaterEqual",function(){return Tu}),n.d(e,"greaterEqualStrict",function(){return Iu}),n.d(e,"greaterStrict",function(){return Du}),n.d(e,"hammingWindow",function(){return Wc}),n.d(e,"hannWindow",function(){return Uc}),n.d(e,"ifft",function(){return Ic}),n.d(e,"imag",function(){return vn}),n.d(e,"image",function(){return ll}),n.d(e,"io",function(){return ff}),n.d(e,"irfft",function(){return jc}),n.d(e,"isFinite",function(){return ys}),n.d(e,"isInf",function(){return bs}),n.d(e,"isNaN",function(){return vs}),n.d(e,"keep",function(){return Ue}),n.d(e,"leakyRelu",function(){return pc}),n.d(e,"less",function(){return ju}),n.d(e,"lessEqual",function(){return Ru}),n.d(e,"lessEqualStrict",function(){return Fu}),n.d(e,"lessStrict",function(){return Pu}),n.d(e,"linalg",function(){return il}),n.d(e,"linspace",function(){return Nn}),n.d(e,"localResponseNormalization",function(){return yc}),n.d(e,"log",function(){return us}),n.d(e,"log1p",function(){return cs}),n.d(e,"logSigmoid",function(){return ls}),n.d(e,"logSoftmax",function(){return $r}),n.d(e,"logSumExp",function(){return xu}),n.d(e,"logicalAnd",function(){return sc}),n.d(e,"logicalNot",function(){return uc}),n.d(e,"logicalOr",function(){return cc}),n.d(e,"logicalXor",function(){return lc}),n.d(e,"losses",function(){return tl}),n.d(e,"matMul",function(){return Zs}),n.d(e,"math",function(){return hf}),n.d(e,"max",function(){return _u}),n.d(e,"maxPool",function(){return uu}),n.d(e,"maximum",function(){return Gu}),n.d(e,"maximumStrict",function(){return Ku}),n.d(e,"mean",function(){return ku}),n.d(e,"memory",function(){return Pe}),n.d(e,"min",function(){return Su}),n.d(e,"minimum",function(){return Xu}),n.d(e,"minimumStrict",function(){return Yu}),n.d(e,"mod",function(){return Ju}),n.d(e,"modStrict",function(){return Zu}),n.d(e,"moments",function(){return Eu}),n.d(e,"movingAverage",function(){return Ac}),n.d(e,"mul",function(){return Qu}),n.d(e,"mulStrict",function(){return tc}),n.d(e,"multiRNNCell",function(){return Oc}),n.d(e,"multinomial",function(){return ar}),n.d(e,"neg",function(){return fs}),n.d(e,"nextFrame",function(){return Lf}),n.d(e,"norm",function(){return wc}),n.d(e,"notEqual",function(){return zu}),n.d(e,"notEqualStrict",function(){return Lu}),n.d(e,"oneHot",function(){return sr}),n.d(e,"ones",function(){return An}),n.d(e,"onesLike",function(){return In}),n.d(e,"op",function(){return pn}),n.d(e,"outerProduct",function(){return tu}),n.d(e,"pad",function(){return ur}),n.d(e,"pad1d",function(){return cr}),n.d(e,"pad2d",function(){return lr}),n.d(e,"pad3d",function(){return fr}),n.d(e,"pad4d",function(){return dr}),n.d(e,"pool",function(){return lu}),n.d(e,"pow",function(){return ec}),n.d(e,"powStrict",function(){return nc}),n.d(e,"prelu",function(){return mc}),n.d(e,"print",function(){return Zn}),n.d(e,"prod",function(){return Au}),n.d(e,"profile",function(){return ze}),n.d(e,"rand",function(){return hr}),n.d(e,"randomNormal",function(){return pr}),n.d(e,"randomUniform",function(){return mr}),n.d(e,"range",function(){return Tn}),n.d(e,"ready",function(){return Ve}),n.d(e,"real",function(){return gn}),n.d(e,"reciprocal",function(){return ds}),n.d(e,"registerBackend",function(){return Xe}),n.d(e,"relu",function(){return gc}),n.d(e,"removeBackend",function(){return $e}),n.d(e,"reshape",function(){return gr}),n.d(e,"reverse",function(){return eu}),n.d(e,"reverse1d",function(){return nu}),n.d(e,"reverse2d",function(){return ru}),n.d(e,"reverse3d",function(){return iu}),n.d(e,"reverse4d",function(){return ou}),n.d(e,"rfft",function(){return Dc}),n.d(e,"round",function(){return hs}),n.d(e,"rsqrt",function(){return ps}),n.d(e,"scalar",function(){return wn}),n.d(e,"scatterND",function(){return Nc}),n.d(e,"selu",function(){return vc}),n.d(e,"separableConv2d",function(){return Ys}),n.d(e,"serialization",function(){return yf}),n.d(e,"setBackend",function(){return qe}),n.d(e,"setPlatform",function(){return Je}),n.d(e,"setdiff1dAsync",function(){return kr}),n.d(e,"sigmoid",function(){return ms}),n.d(e,"sign",function(){return gs}),n.d(e,"signal",function(){return Vc}),n.d(e,"sin",function(){return ws}),n.d(e,"sinh",function(){return xs}),n.d(e,"slice",function(){return fu}),n.d(e,"slice1d",function(){return du}),n.d(e,"slice2d",function(){return hu}),n.d(e,"slice3d",function(){return pu}),n.d(e,"slice4d",function(){return mu}),n.d(e,"softmax",function(){return Hr}),n.d(e,"softplus",function(){return _s}),n.d(e,"spaceToBatchND",function(){return vr}),n.d(e,"sparseToDense",function(){return Fc}),n.d(e,"spectral",function(){return Rc}),n.d(e,"split",function(){return Ln}),n.d(e,"sqrt",function(){return ks}),n.d(e,"square",function(){return Ss}),n.d(e,"squaredDifference",function(){return rc}),n.d(e,"squaredDifferenceStrict",function(){return ic}),n.d(e,"squeeze",function(){return br}),n.d(e,"stack",function(){return yr}),n.d(e,"step",function(){return Es}),n.d(e,"stridedSlice",function(){return Cc}),n.d(e,"sub",function(){return oc}),n.d(e,"subStrict",function(){return ac}),n.d(e,"sum",function(){return Ou}),n.d(e,"tan",function(){return Os}),n.d(e,"tanh",function(){return As}),n.d(e,"tensor",function(){return bn}),n.d(e,"tensor1d",function(){return xn}),n.d(e,"tensor2d",function(){return _n}),n.d(e,"tensor3d",function(){return kn}),n.d(e,"tensor4d",function(){return Sn}),n.d(e,"tensor5d",function(){return En}),n.d(e,"tensor6d",function(){return On}),n.d(e,"tensor_util",function(){return Tt}),n.d(e,"test_util",function(){return Ef}),n.d(e,"tidy",function(){return Le}),n.d(e,"tile",function(){return wr}),n.d(e,"time",function(){return We}),n.d(e,"topk",function(){return Mc}),n.d(e,"train",function(){return Pf}),n.d(e,"transpose",function(){return bc}),n.d(e,"truncatedNormal",function(){return xr}),n.d(e,"unsortedSegmentSum",function(){return Sc}),n.d(e,"unstack",function(){return _r}),n.d(e,"util",function(){return rt}),n.d(e,"valueAndGrad",function(){return Br}),n.d(e,"valueAndGrads",function(){return Ur}),n.d(e,"variable",function(){return kt}),n.d(e,"variableGrads",function(){return Wr}),n.d(e,"version_core",function(){return Of}),n.d(e,"webgl",function(){return Af}),n.d(e,"where",function(){return fc}),n.d(e,"whereAsync",function(){return dc}),n.d(e,"zeros",function(){return Cn}),n.d(e,"zerosLike",function(){return Dn});
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(a,s)}u((r=r.apply(t,e||[])).next())})}function l(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var f=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}return t.prototype.setPlatform=function(t,e){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+"."),this.platformName=t,this.platform=e},t.prototype.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];console.warn("Setting feature override from URL "+t+": "+r+"."),this.set(t,r)}},t.prototype.get=function(t){return t in this.flags?this.flags[t]:(this.flags[t]=this.evaluateFlag(t),this.flags[t])},t.prototype.getNumber=function(t){return this.get(t)},t.prototype.getBool=function(t){return this.get(t)},t.prototype.getFlags=function(){return this.flags},Object.defineProperty(t.prototype,"features",{get:function(){return this.flags},enumerable:!0,configurable:!0}),t.prototype.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e)},t.prototype.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn()},t.prototype.setFlags=function(t){this.flags=Object.assign({},t)},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},t.prototype.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e=d(this.global.location.search);"tfjsflags"in e&&e.tfjsflags.split(",").forEach(function(e){var n=e.split(":"),r=n[0],i=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return"true"===e;if(""+ +e===e)return+e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".")}(r,i)})}},t}();function d(t){var e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(e,n[0],n[1]),n.join("=")}),e}var h=null;function p(t){h=t}var m=Object.freeze({Environment:f,getQueryParams:d,get ENV(){return h},setEnvironmentGlobal:p});function g(t){for(var e=t.length,n=0,r=0;e>0;)r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n}function v(t,e,n){return Math.max(t,Math.min(e,n))}function b(t){return t%2==0?t:t+1}function y(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return e}function w(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function x(t,e,n){void 0===n&&(n=""),w(E(t,e),function(){return n+" Shapes "+t+" and "+e+" must match"})}function _(t){w(null!=t,function(){return"The input to the tensor constructor must be a non-null value."})}function k(t,e){if(void 0===e&&(e=[]),null==e&&(e=[]),Array.isArray(t)||B(t))for(var n=0;n<t.length;++n)k(t[n],e);else e.push(t);return e}function S(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function E(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function O(t){return t%1==0}function A(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return-1;var e=Math.exp(2*t);return(e-1)/(e+1)}function C(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function M(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function N(t,e,n){return void 0===e&&(e=function(t){return 0}),new Promise(function(r,i){var o=0,a=function(){if(t())r();else{var s=e(++o);null!=n&&o>=n?i():setTimeout(a,s)}};a()})}function T(t,e){for(var n=1,r=-1,i=0;i<t.length;++i)if(t[i]>=0)n*=t[i];else if(-1===t[i]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+i);r=i}else if(t[i]<0)throw Error("Shapes can not be < 0. Found "+t[i]+" at dim "+i);if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var o=t.slice();return o[r]=e/n,o}function I(t,e){var n=e.length;return w((t=null==t?e.map(function(t,e){return e}):[].concat(t)).every(function(t){return t>=-n&&t<n}),function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+t}),w(t.every(function(t){return O(t)}),function(){return"All values in axis param must be integers but got axis "+t}),t.map(function(t){return t<0?n+t:t})}function D(t,e){for(var n=[],r=[],i=null==e?null:I(e,t).sort(),o=0,a=0;a<t.length;++a){if(null!=i){if(i[o]===a&&1!==t[a])throw new Error("Can't squeeze axis "+a+" since its dim '"+t[a]+"' is not 1");(null==i[o]||i[o]>a)&&1===t[a]&&(n.push(t[a]),r.push(a)),i[o]<=a&&o++}1!==t[a]&&(n.push(t[a]),r.push(a))}return{newShape:n,keptDims:r}}function j(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else{if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e)}return n}function R(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e)}return n}function F(t,e,n){if("float32"===e)for(var r=0;r<t.length;r++){var i=t[r];if(isNaN(i)||!isFinite(i))throw Error("The result of the '"+n+"' is "+i+".")}}function P(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".")}}function z(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function L(t,e){return!("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t)}function B(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function U(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t)}function W(t){if(null==t)return 0;var e=0;return t.forEach(function(t){return e+=2*t.length}),e}function q(t){return"string"==typeof t||t instanceof String}function V(t){return"boolean"==typeof t}function H(t){return"number"==typeof t}function $(t){return Array.isArray(t)?$(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":H(t)?"float32":q(t)?"string":V(t)?"bool":"float32"}function G(t){return!!(t&&t.constructor&&t.call&&t.apply)}function K(t,e){for(var n=e;n<t;++n)if(t%n==0)return n;return t}function X(t){var e=t.length;if(e<2)return[];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r)n[r]=n[r+1]*t[r+1];return n}function Y(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=k(t)),n&&P(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),i=0;i<r.length;++i)0!==Math.round(t[i])&&(r[i]=1);return r}throw new Error("Unknown data type "+e)}function J(t,e){if(0===t.length)return e[0];var n=t.reduce(function(t,e){return t*e});if(0===n)return[];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var i=new Array;if(1===n.length)for(var o=n[0],a=0;a<o;a++)i[a]=r[e+a];else{o=n[0];var s=n.slice(1),u=s.reduce(function(t,e){return t*e});for(a=0;a<o;a++)i[a]=t(e+a*u,s,r)}return i}(0,t,e)}function Z(t,e){for(var n=Q(t,e),r=0;r<n.length;r++)n[r]=1;return n}function Q(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e)}function tt(){if("undefined"!=typeof performance)return performance.now();if(void 0!==t){var e=t.hrtime();return 1e3*e[0]+e[1]/1e6}throw new Error("Cannot measure time in this environment. You should run tf.js in the browser or in Node.js")}function et(t){t.forEach(function(e){w(Number.isInteger(e)&&e>=0,function(){return"Tensor must have a shape comprised of positive integers but got shape ["+t+"]."})})}function nt(t,e){return h.platform.fetch(t,e)}var rt=Object.freeze({shuffle:g,clamp:v,nearestLargerEven:b,sum:y,randUniform:function(t,e){var n=Math.random();return e*n+(1-n)*t},distSquared:function(t,e){for(var n=0,r=0;r<t.length;r++){var i=Number(t[r])-Number(e[r]);n+=i*i}return n},assert:w,assertShapesMatch:x,assertNonNull:_,flatten:k,sizeFromShape:S,isScalarShape:function(t){return 0===t.length},arraysEqual:E,isInt:O,tanh:A,sizeToSquarishShape:C,createShuffledIndices:function(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return g(e),e},rightPad:M,repeatedTry:N,inferFromImplicitShape:T,parseAxisParam:I,squeezeShape:D,getTypedArrayFromDType:j,getArrayFromDType:R,checkComputationForErrors:F,checkConversionForErrors:P,isValidDtype:z,hasEncodingLoss:L,isTypedArray:B,bytesPerElement:U,bytesFromStringArray:W,isString:q,isBoolean:V,isNumber:H,inferDtype:$,isFunction:G,nearestDivisor:K,computeStrides:X,toTypedArray:Y,toNestedArray:J,makeOnesTypedArray:Z,makeZerosTypedArray:Q,now:tt,assertNonNegativeIntegerDimensions:et,fetch:nt}),it=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new ot)}return t.prototype.profileKernel=function(t,e){var n,r=this,i=this.backendTimer.time(function(){n=e()});return(Array.isArray(n)?n:[n]).forEach(function(e){var n=e.dataSync();F(n,e.dtype,t),i.then(function(i){var o="";null!=i.getExtraProfileInfo&&(o=i.getExtraProfileInfo()),r.logger.logKernelProfile(t,e,n,i.kernelMs,o)})}),n},t}(),ot=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,i){var o=M(r+"ms",9),a=M(t,25),s=e.rank,u=e.size,c=M(e.shape.toString(),14);console.log("%c"+a+"\t%c"+o+"\t%c"+s+"D "+c+"\t%c"+u+"\t%c"+i,"font-weight:bold","color:red","color:blue","color: orange","color: green")},t}(),at=20,st=3,ut=7;function ct(t,e,n){return M(Array.isArray(t)?parseFloat(t[0].toFixed(ut))+" + "+parseFloat(t[1].toFixed(ut))+"j":q(t)?"'"+t+"'":"bool"===n?lt(t):parseFloat(t.toFixed(ut)).toString(),e)}function lt(t){return 0===t?"false":"true"}function ft(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var dt=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=S(t),null!=n){var i=n.length;w(i===this.size,function(){return"Length of values '"+i+"' does not match the size inferred by the shape '"+r.size+"'."})}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||R(e,this.size),this.strides=X(t)}return t.prototype.set=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===n.length&&(n=[0]),w(n.length===this.rank,function(){return"The number of provided coordinates ("+n.length+") must match the rank ("+e.rank+")"});var i=this.locToIndex(n);this.values[i]=t},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];0===t.length&&(t=[0]);for(var n=0,r=0,i=t;r<i.length;r++){var o=i[r];if(o<0||o>=this.shape[n]){var a="Requested out of range element at "+t+". Buffer shape="+this.shape;throw new Error(a)}n++}for(var s=t[t.length-1],u=0;u<t.length-1;++u)s+=this.strides[u]*t[u];return this.values[s]},t.prototype.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n)e+=this.strides[n]*t[n];return e},t.prototype.indexToLoc=function(t){if(0===this.rank)return[];if(1===this.rank)return[t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n)e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];return e[e.length-1]=t,e},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return gt.make(this.shape,{values:this.values},this.dtype)},t}(),ht=null,pt=null,mt=null,gt=function(){function t(t,e,n,r,i){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=S(t),this.strides=X(t),this.dataId=null!=r?r:{},this.id=ht().nextTensorId(),this.rankType=this.rank<5?this.rank.toString():"higher",ht().registerTensor(this,i),null!=n&&ht().write(i,this.dataId,n)}return t.make=function(e,n,r,i){return new t(e,r,n.values,n.dataId,i)},t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D()},t.prototype.asScalar=function(){return this.throwIfDisposed(),w(1===this.size,function(){return"The array must have only 1 element."}),this.reshape([])},t.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size])},t.prototype.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e])},t.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n])},t.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r])},t.prototype.as5D=function(t,e,n,r,i){return this.throwIfDisposed(),this.reshape([t,e,n,r,i])},t.prototype.asType=function(t){return this.throwIfDisposed(),pt.cast(this,t)},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return c(this,void 0,void 0,function(){var t;return l(this,function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,pt.buffer(this.shape,this.dtype,t)]}})})},t.prototype.bufferSync=function(){return pt.buffer(this.shape,this.dtype,this.dataSync())},t.prototype.array=function(){return c(this,void 0,void 0,function(){var t;return l(this,function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,J(this.shape,t)]}})})},t.prototype.arraySync=function(){return J(this.shape,this.dataSync())},t.prototype.data=function(){return c(this,void 0,void 0,function(){return l(this,function(t){return this.throwIfDisposed(),[2,ht().read(this.dataId)]})})},t.prototype.dataSync=function(){return this.throwIfDisposed(),ht().readSync(this.dataId)},t.prototype.dispose=function(){this.isDisposed||(ht().disposeTensor(this),this.isDisposedInternal=!0)},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this.isDisposedInternal},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},t.prototype.toFloat=function(){return this.asType("float32")},t.prototype.toInt=function(){return this.asType("int32")},t.prototype.toBool=function(){return this.asType("bool")},t.prototype.print=function(t){return void 0===t&&(t=!1),pt.print(this,t)},t.prototype.reshape=function(t){return this.throwIfDisposed(),pt.reshape(this,t)},t.prototype.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape)},t.prototype.expandDims=function(t){return void 0===t&&(t=0),pt.expandDims(this,t)},t.prototype.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),pt.cumsum(this,t,e,n)},t.prototype.squeeze=function(t){return this.throwIfDisposed(),pt.squeeze(this,t)},t.prototype.clone=function(){return this.throwIfDisposed(),pt.clone(this)},t.prototype.oneHot=function(t,e,n){return this.throwIfDisposed(),pt.oneHot(this,t,e,n)},t.prototype.toString=function(t){return void 0===t&&(t=!1),function(t,e,n,r){var i=X(e),o=function(t,e,n,r){var i=S(e),o=r[r.length-1],a=new Array(o).fill(0),s=e.length,u="complex64"===n?ft(t):t;if(s>1)for(var c=0;c<i/o;c++)for(var l=c*o,f=0;f<o;f++)a[f]=Math.max(a[f],ct(u[l+f],0,n).length);return a}(t,e,n,i),a=e.length,s=function t(e,n,r,i,o,a){void 0===a&&(a=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return"complex64"===r?[ct(ft(e)[0],0,r)]:"bool"===r?[lt(e[0])]:[e[0].toString()];if(1===c){if(u>at){var l=st*s,f=Array.from(e.slice(0,l)),d=Array.from(e.slice(u-st*s,u));return"complex64"===r&&(f=ft(f),d=ft(d)),["["+f.map(function(t,e){return ct(t,o[e],r)}).join(", ")+", ..., "+d.map(function(t,e){return ct(t,o[u-st+e],r)}).join(", ")+"]"]}return["["+("complex64"===r?ft(e):Array.from(e)).map(function(t,e){return ct(t,o[e],r)}).join(", ")+"]"]}var h=n.slice(1),p=i.slice(1),m=i[0]*s,g=[];if(u>at){for(var v=0;v<st;v++){var b=(y=v*m)+m;g.push.apply(g,t(e.slice(y,b),h,r,p,o,!1))}for(g.push("..."),v=u-st;v<u;v++)b=(y=v*m)+m,g.push.apply(g,t(e.slice(y,b),h,r,p,o,v===u-1))}else for(v=0;v<u;v++){var y;b=(y=v*m)+m,g.push.apply(g,t(e.slice(y,b),h,r,p,o,v===u-1))}var w=2===c?",":"";for(g[0]="["+g[0]+w,v=1;v<g.length-1;v++)g[v]=" "+g[v]+w;var x=",\n";for(v=2;v<c;v++)x+="\n";return g[g.length-1]=" "+g[g.length-1]+"]"+(a?"":x),g}(t,e,n,i,o),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+a),u.push(" shape: ["+e+"]"),u.push(" values:")),u.push(s.map(function(t){return" "+t}).join("\n")),u.join("\n")}(this.dataSync(),this.shape,this.dtype,t)},t.prototype.tile=function(t){return this.throwIfDisposed(),pt.tile(this,t)},t.prototype.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),pt.gather(this,t,e)},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),pt.matMul(this,t,e,n)},t.prototype.dot=function(t){return this.throwIfDisposed(),pt.dot(this,t)},t.prototype.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),pt.norm(this,t,e,n)},t.prototype.slice=function(t,e){return this.throwIfDisposed(),pt.slice(this,t,e)},t.prototype.reverse=function(t){return this.throwIfDisposed(),pt.reverse(this,t)},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),pt.concat([this].concat(e),n)},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),pt.split(this,t,e)},t.prototype.stack=function(t,e){return void 0===e&&(e=0),pt.stack([this,t],e)},t.prototype.unstack=function(t){return void 0===t&&(t=0),pt.unstack(this,t)},t.prototype.pad=function(t,e){return void 0===e&&(e=0),pt.pad(this,t,e)},t.prototype.batchNormalization=function(t,e,n,r,i){return void 0===n&&(n=.001),mt("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(t,e,i,r,n)},t.prototype.batchNorm=function(t,e,n,r,i){return void 0===i&&(i=.001),this.throwIfDisposed(),pt.batchNorm(this,t,e,n,r,i)},t.prototype.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.all(this,t,e)},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.any(this,t,e)},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.logSumExp(this,t,e)},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.sum(this,t,e)},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.prod(this,t,e)},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.mean(this,t,e)},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.min(this,t,e)},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),pt.max(this,t,e)},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),pt.argMin(this,t)},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),pt.argMax(this,t)},t.prototype.cast=function(t){return this.throwIfDisposed(),pt.cast(this,t)},t.prototype.add=function(t){return this.throwIfDisposed(),pt.add(this,t)},t.prototype.addStrict=function(t){return this.throwIfDisposed(),pt.addStrict(this,t)},t.prototype.atan2=function(t){return this.throwIfDisposed(),pt.atan2(this,t)},t.prototype.sub=function(t){return this.throwIfDisposed(),pt.sub(this,t)},t.prototype.subStrict=function(t){return this.throwIfDisposed(),pt.subStrict(this,t)},t.prototype.pow=function(t){return this.throwIfDisposed(),pt.pow(this,t)},t.prototype.powStrict=function(t){return this.throwIfDisposed(),pt.powStrict(this,t)},t.prototype.mul=function(t){return this.throwIfDisposed(),pt.mul(this,t)},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),pt.mulStrict(this,t)},t.prototype.div=function(t){return this.throwIfDisposed(),pt.div(this,t)},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),pt.floorDiv(this,t)},t.prototype.divStrict=function(t){return this.throwIfDisposed(),pt.divStrict(this,t)},t.prototype.minimum=function(t){return this.throwIfDisposed(),pt.minimum(this,t)},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),pt.minimumStrict(this,t)},t.prototype.maximum=function(t){return this.throwIfDisposed(),pt.maximum(this,t)},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),pt.maximumStrict(this,t)},t.prototype.mod=function(t){return this.throwIfDisposed(),pt.mod(this,t)},t.prototype.modStrict=function(t){return this.throwIfDisposed(),pt.modStrict(this,t)},t.prototype.squaredDifference=function(t){return this.throwIfDisposed(),pt.squaredDifference(this,t)},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),pt.squaredDifferenceStrict(this,t)},t.prototype.transpose=function(t){return this.throwIfDisposed(),pt.transpose(this,t)},t.prototype.notEqual=function(t){return this.throwIfDisposed(),pt.notEqual(this,t)},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),pt.notEqualStrict(this,t)},t.prototype.less=function(t){return this.throwIfDisposed(),pt.less(this,t)},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),pt.lessStrict(this,t)},t.prototype.equal=function(t){return this.throwIfDisposed(),pt.equal(this,t)},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),pt.equalStrict(this,t)},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),pt.lessEqual(this,t)},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),pt.lessEqualStrict(this,t)},t.prototype.greater=function(t){return this.throwIfDisposed(),pt.greater(this,t)},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),pt.greaterStrict(this,t)},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),pt.greaterEqual(this,t)},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),pt.greaterEqualStrict(this,t)},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),pt.logicalAnd(this,t)},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),pt.logicalOr(this,t)},t.prototype.logicalNot=function(){return this.throwIfDisposed(),pt.logicalNot(this)},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),pt.logicalXor(this,t)},t.prototype.where=function(t,e){return this.throwIfDisposed(),pt.where(t,this,e)},t.prototype.neg=function(){return this.throwIfDisposed(),pt.neg(this)},t.prototype.ceil=function(){return this.throwIfDisposed(),pt.ceil(this)},t.prototype.floor=function(){return this.throwIfDisposed(),pt.floor(this)},t.prototype.sign=function(){return this.throwIfDisposed(),pt.sign(this)},t.prototype.isNaN=function(){return this.throwIfDisposed(),pt.isNaN(this)},t.prototype.isInf=function(){return this.throwIfDisposed(),pt.isInf(this)},t.prototype.isFinite=function(){return this.throwIfDisposed(),pt.isFinite(this)},t.prototype.exp=function(){return this.throwIfDisposed(),pt.exp(this)},t.prototype.expm1=function(){return this.throwIfDisposed(),pt.expm1(this)},t.prototype.log=function(){return this.throwIfDisposed(),pt.log(this)},t.prototype.log1p=function(){return this.throwIfDisposed(),pt.log1p(this)},t.prototype.sqrt=function(){return this.throwIfDisposed(),pt.sqrt(this)},t.prototype.rsqrt=function(){return this.throwIfDisposed(),pt.rsqrt(this)},t.prototype.square=function(){return this.throwIfDisposed(),pt.square(this)},t.prototype.reciprocal=function(){return this.throwIfDisposed(),pt.reciprocal(this)},t.prototype.abs=function(){return this.throwIfDisposed(),pt.abs(this)},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),pt.clipByValue(this,t,e)},t.prototype.relu=function(){return this.throwIfDisposed(),pt.relu(this)},t.prototype.elu=function(){return this.throwIfDisposed(),pt.elu(this)},t.prototype.selu=function(){return this.throwIfDisposed(),pt.selu(this)},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),pt.leakyRelu(this,t)},t.prototype.prelu=function(t){return this.throwIfDisposed(),pt.prelu(this,t)},t.prototype.sigmoid=function(){return this.throwIfDisposed(),pt.sigmoid(this)},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),pt.logSigmoid(this)},t.prototype.softplus=function(){return this.throwIfDisposed(),pt.softplus(this)},t.prototype.zerosLike=function(){return this.throwIfDisposed(),pt.zerosLike(this)},t.prototype.onesLike=function(){return this.throwIfDisposed(),pt.onesLike(this)},t.prototype.sin=function(){return this.throwIfDisposed(),pt.sin(this)},t.prototype.cos=function(){return this.throwIfDisposed(),pt.cos(this)},t.prototype.tan=function(){return this.throwIfDisposed(),pt.tan(this)},t.prototype.asin=function(){return this.throwIfDisposed(),pt.asin(this)},t.prototype.acos=function(){return this.throwIfDisposed(),pt.acos(this)},t.prototype.atan=function(){return this.throwIfDisposed(),pt.atan(this)},t.prototype.sinh=function(){return this.throwIfDisposed(),pt.sinh(this)},t.prototype.cosh=function(){return this.throwIfDisposed(),pt.cosh(this)},t.prototype.tanh=function(){return this.throwIfDisposed(),pt.tanh(this)},t.prototype.asinh=function(){return this.throwIfDisposed(),pt.asinh(this)},t.prototype.acosh=function(){return this.throwIfDisposed(),pt.acosh(this)},t.prototype.atanh=function(){return this.throwIfDisposed(),pt.atanh(this)},t.prototype.erf=function(){return this.throwIfDisposed(),pt.erf(this)},t.prototype.round=function(){return this.throwIfDisposed(),pt.round(this)},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),pt.step(this,t)},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),pt.softmax(this,t)},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),pt.logSoftmax(this,t)},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),pt.image.resizeBilinear(this,t,e)},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),pt.image.resizeNearestNeighbor(this,t,e)},t.prototype.conv1d=function(t,e,n,r,i,o){return void 0===r&&(r="NWC"),void 0===i&&(i=1),this.throwIfDisposed(),pt.conv1d(this,t,e,n,r,i,o)},t.prototype.conv2d=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),pt.conv2d(this,t,e,n,r,i,o)},t.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),pt.conv2dTranspose(this,t,e,n,r,i)},t.prototype.depthwiseConv2D=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),pt.depthwiseConv2d(this,t,e,n,r,i,o)},t.prototype.separableConv2d=function(t,e,n,r,i,o){return void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC"),this.throwIfDisposed(),pt.separableConv2d(this,t,e,n,r,i,o)},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),pt.avgPool(this,t,e,n,r)},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),pt.maxPool(this,t,e,n,r)},t.prototype.localResponseNormalization=function(t,e,n,r){return void 0===t&&(t=5),void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=.5),pt.localResponseNormalization(this,t,e,n,r)},t.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),pt.pool(this,t,e,n,r,i)},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),vt.variable(this,t,e,n)},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),pt.unsortedSegmentSum(this,t,e)},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),pt.batchToSpaceND(this,t,e)},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),pt.spaceToBatchND(this,t,e)},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),pt.topk(this,t,e)},t.prototype.stridedSlice=function(t,e,n,r,i,o,a,s){return void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),this.throwIfDisposed(),pt.stridedSlice(this,t,e,n,r,i,o,a,s)},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),pt.depthToSpace(this,t,e)},t.prototype.fft=function(){return this.throwIfDisposed(),pt.spectral.fft(this)},t.prototype.ifft=function(){return this.throwIfDisposed(),pt.spectral.ifft(this)},t.prototype.rfft=function(){return this.throwIfDisposed(),pt.spectral.rfft(this)},t.prototype.irfft=function(){return this.throwIfDisposed(),pt.spectral.irfft(this)},t}();Object.defineProperty(gt,Symbol.hasInstance,{value:function(t){return!!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype}});var vt=function(t){function e(e,n,r){void 0===n&&(n=!0);var i=t.call(this,e.shape,e.dtype,null,e.dataId)||this;i.trainable=n,i.name=r,null==i.name&&(i.name=ht().nextVariableId().toString());try{ht().registerVariable(i)}catch(t){throw ht().disposeTensor(i),t}return i}return s(e,t),e.variable=function(t,n,r,i){return void 0===n&&(n=!0),null!=i&&i!==t.dtype&&(t=t.asType(i)),new e(t,n,r)},e.prototype.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!E(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");ht().disposeTensor(this),this.dataId=t.dataId,ht().registerTensor(this)},e.prototype.dispose=function(){ht().disposeVariable(this),this.isDisposedInternal=!0},e}(gt);Object.defineProperty(vt,Symbol.hasInstance,{value:function(t){return t instanceof gt&&null!=t.assign&&t.assign instanceof Function}});var bt,yt,wt,xt,_t,kt=vt.variable;!function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(bt||(bt={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(yt||(yt={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(wt||(wt={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(xt||(xt={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(_t||(_t={}));var St={float32:xt,int32:yt,bool:wt,complex64:_t};function Et(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error("Can not upcast "+t+" with "+e)}return St[t][e]}function Ot(t){return Et(t,"int32")}function At(t,e){if(t.dtype===e.dtype)return[t,e];var n=Et(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Ct(t,e){w(t.dtype===e.dtype,function(){return"The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match"})}function Mt(t){var e=[];return function t(e,n,r){if(null!=e)if(e instanceof gt)n.push(e);else if(i=e,Array.isArray(i)||"object"==typeof i){var i,o=e;for(var a in o){var s=o[a];r.has(s)||(r.add(s),t(s,n,r))}}}(t,e,new Set),e}var Nt,Tt=Object.freeze({makeTypesMatch:At,assertTypesMatch:Ct,isTensorInList:function(t,e){for(var n=0;n<e.length;n++)if(e[n].id===t.id)return!0;return!1},getTensorsInContainer:Mt}),It=function(){function t(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null}}return t.prototype.dispose=function(){for(var t in this.registeredVariables)this.registeredVariables[t].dispose()},t}(),Dt=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new It}return t.prototype.ready=function(){return c(this,void 0,void 0,function(){var t,e,n;return l(this,function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return[2,this.pendingBackendInit.then(function(){})];if(null!=this.backendInstance)return[2];t=this.getSortedBackends(),e=0,r.label=1;case 1:return e<t.length?(n=t[e],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return e++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.")}})})},Object.defineProperty(t.prototype,"backend",{get:function(){if(null!=this.pendingBackendInit)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() before calling other methods");this.setBackend(e)}return this.backendInstance},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory)},t.prototype.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null}return this.registry[t]},t.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null},t.prototype.registerBackend=function(t,e,n){return void 0===n&&(n=1),t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0)},t.prototype.setBackend=function(t){return c(this,void 0,void 0,function(){var e,n,r;return l(this,function(i){switch(i.label){case 0:if(null==this.registryFactory[t])throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,null!=this.registry[t]?[3,4]:(this.backendInstance=null,e=this.initializeBackend(t),n=e.success,e.asyncInit?[4,n]:[3,2]);case 1:return r=i.sent(),[3,3];case 2:r=n,i.label=3;case 3:if(!r)return[2,!1];i.label=4;case 4:return this.backendInstance=this.registry[t],this.profiler=new it(this.backendInstance),[2,!0]}})})},t.prototype.initializeBackend=function(t){var e=this,n=jt.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var i=++this.pendingBackendInitId,o=r.then(function(n){return!(i<e.pendingBackendInitId||(e.registry[t]=n,e.pendingBackendInit=null,0))}).catch(function(n){return!(i<e.pendingBackendInitId||(e.pendingBackendInit=null,console.warn("Initialization of backend "+t+" failed"),console.warn(n.stack||n.message),1))});return this.pendingBackendInit=o,{success:o,asyncInit:!0}}return this.registry[t]=r,{success:!0,asyncInit:!1}}catch(e){return console.warn("Initialization of backend "+t+" failed"),console.warn(e.stack||e.message),{success:!1,asyncInit:!1}}},t.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},t.prototype.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(function(e,n){return t.registryFactory[n].priority-t.registry