UNPKG

hand-it

Version:

Easily add hand gestures to your react app

2 lines 3.16 MB
/*! For license information please see index.js.LICENSE.txt */ module.exports=(()=>{var t={249:(t,e,n)=>{"use strict";n.r(e),n.d(e,{HandGest:()=>d,poseParameters:()=>l});var r,i,a,o=n(698),s=n.n(o),u=n(970),c=n(436),l={pose1:"Point Up",pose2:"Point Down",pose3:"OK",pose4:"Fist",classifySpeed:300,webcamWidth:640,webcamHeight:480,pose1Action:function(){},pose2Action:function(){},pose3Action:function(){},pose4Action:function(){}};function f(t,e,n,r,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function d(){var t=!1,e=(0,o.useRef)(null),n=function(){var n,o=(n=regeneratorRuntime.mark((function n(){var o,s,u,f,p,m,g;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return g=function(){console.log("brain ready")},f=function(){console.log("Model Loaded!"),t=!0,setInterval((function(){!function(){if(a&&t){i=[];for(var e=0;e<a.landmarks.length;e++)i.push(a.landmarks[e][0]),i.push(a.landmarks[e][1]),i.push(a.landmarks[e][2]);r.classify(i,h)}}()}),l.classifySpeed)},n.next=4,e.current.video;case 4:o=n.sent,s=o.videoWidth,u=o.videoHeight,o.width=s,o.height=u,c.handpose(o,f).on("predict",d),p={inputs:63,outputs:11,task:"classification",debug:!0},r=c.neuralNetwork(p),m={model:"data/model.json",metadata:"data/model_meta.json",weights:"data/model.weights.bin"},r.load(m,g);case 15:case"end":return n.stop()}}),n)})),function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){f(a,r,i,o,s,"next",t)}function s(t){f(a,r,i,o,s,"throw",t)}o(void 0)}))});return function(){return o.apply(this,arguments)}}();function d(e){e.length>0?(t=!0,a=e[0]):t=!1}function h(t,e){if(e&&e[0].confidence>.9){var n=e[0].label;console.log(n),n===l.pose1?l.pose1Action():n===l.pose2?l.pose2Action():n===l.pose3?l.pose3Action():n===l.pose4&&l.pose4Action()}}return(0,o.useEffect)((function(){n()}),[]),s().createElement("div",null,s().createElement(u,{ref:e,audio:!1,mirrored:!0,style:{width:l.webcamWidth,height:l.webcamHeight}}))}},436:t=>{window,t.exports=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=693)}([function(t,e,n){"use strict";n.r(e),function(t,r,i,a){n.d(e,"AdadeltaOptimizer",(function(){return fd})),n.d(e,"AdagradOptimizer",(function(){return dd})),n.d(e,"AdamOptimizer",(function(){return hd})),n.d(e,"AdamaxOptimizer",(function(){return pd})),n.d(e,"Add",(function(){return yr})),n.d(e,"AddN",(function(){return br})),n.d(e,"BroadcastTo",(function(){return Sr})),n.d(e,"DataStorage",(function(){return oa})),n.d(e,"Div",(function(){return xr})),n.d(e,"ENV",(function(){return d})),n.d(e,"Environment",(function(){return l})),n.d(e,"FromPixels",(function(){return Ir})),n.d(e,"FusedBatchNorm",(function(){return wr})),n.d(e,"Identity",(function(){return Ar})),n.d(e,"KernelBackend",(function(){return sa})),n.d(e,"MaxPoolWithArgmax",(function(){return Dr})),n.d(e,"MomentumOptimizer",(function(){return gd})),n.d(e,"NonMaxSuppressionV5",(function(){return Or})),n.d(e,"OneHot",(function(){return Cr})),n.d(e,"Optimizer",(function(){return ld})),n.d(e,"PadV2",(function(){return Tr})),n.d(e,"RMSPropOptimizer",(function(){return vd})),n.d(e,"Rank",(function(){return _t})),n.d(e,"Reduction",(function(){return tl})),n.d(e,"SGDOptimizer",(function(){return md})),n.d(e,"Square",(function(){return _r})),n.d(e,"SquaredDifference",(function(){return kr})),n.d(e,"Tensor",(function(){return kt})),n.d(e,"TensorBuffer",(function(){return yt})),n.d(e,"Tile",(function(){return Nr})),n.d(e,"Transpose",(function(){return Er})),n.d(e,"Variable",(function(){return At})),n.d(e,"abs",(function(){return Pr})),n.d(e,"acos",(function(){return Lr})),n.d(e,"acosh",(function(){return zr})),n.d(e,"add",(function(){return Mr})),n.d(e,"addN",(function(){return Ss})),n.d(e,"addStrict",(function(){return vi})),n.d(e,"all",(function(){return bc})),n.d(e,"any",(function(){return xc})),n.d(e,"argMax",(function(){return wc})),n.d(e,"argMin",(function(){return kc})),n.d(e,"asin",(function(){return Br})),n.d(e,"asinh",(function(){return Ur})),n.d(e,"atan",(function(){return Wr})),n.d(e,"atan2",(function(){return yi})),n.d(e,"atanh",(function(){return Vr})),n.d(e,"avgPool",(function(){return uc})),n.d(e,"avgPool3d",(function(){return fc})),n.d(e,"backend",(function(){return ln})),n.d(e,"backend_util",(function(){return Ea})),n.d(e,"basicLSTMCell",(function(){return Lc})),n.d(e,"batchNorm",(function(){return Ds})),n.d(e,"batchNorm2d",(function(){return Fs})),n.d(e,"batchNorm3d",(function(){return Ls})),n.d(e,"batchNorm4d",(function(){return Us})),n.d(e,"batchNormalization",(function(){return Is})),n.d(e,"batchNormalization2d",(function(){return Rs})),n.d(e,"batchNormalization3d",(function(){return Ps})),n.d(e,"batchNormalization4d",(function(){return Bs})),n.d(e,"batchToSpaceND",(function(){return nr})),n.d(e,"booleanMaskAsync",(function(){return ju})),n.d(e,"broadcastTo",(function(){return Ws})),n.d(e,"browser",(function(){return rd})),n.d(e,"buffer",(function(){return tr})),n.d(e,"cast",(function(){return rr})),n.d(e,"ceil",(function(){return qr})),n.d(e,"clipByValue",(function(){return Hr})),n.d(e,"clone",(function(){return Vs})),n.d(e,"complex",(function(){return An})),n.d(e,"concat",(function(){return Kn})),n.d(e,"concat1d",(function(){return Xn})),n.d(e,"concat2d",(function(){return Yn})),n.d(e,"concat3d",(function(){return Jn})),n.d(e,"concat4d",(function(){return Zn})),n.d(e,"conv1d",(function(){return Bu})),n.d(e,"conv2d",(function(){return Uu})),n.d(e,"conv2dTranspose",(function(){return Xu})),n.d(e,"conv3d",(function(){return Wu})),n.d(e,"conv3dTranspose",(function(){return Yu})),n.d(e,"cos",(function(){return Gr})),n.d(e,"cosh",(function(){return $r})),n.d(e,"cumsum",(function(){return ir})),n.d(e,"customGrad",(function(){return ea})),n.d(e,"deprecationWarn",(function(){return $e})),n.d(e,"depthToSpace",(function(){return ar})),n.d(e,"depthwiseConv2d",(function(){return Hu})),n.d(e,"diag",(function(){return Jc})),n.d(e,"disableDeprecationWarnings",(function(){return Ge})),n.d(e,"dispose",(function(){return Qe})),n.d(e,"disposeVariables",(function(){return Ke})),n.d(e,"div",(function(){return Ri})),n.d(e,"divNoNan",(function(){return Ys})),n.d(e,"divStrict",(function(){return bi})),n.d(e,"dot",(function(){return Zu})),n.d(e,"dropout",(function(){return Zc})),n.d(e,"elu",(function(){return Tc})),n.d(e,"enableDebugMode",(function(){return He})),n.d(e,"enableProdMode",(function(){return qe})),n.d(e,"engine",(function(){return Xe})),n.d(e,"env",(function(){return f})),n.d(e,"equal",(function(){return xu})),n.d(e,"equalStrict",(function(){return wu})),n.d(e,"erf",(function(){return Kr})),n.d(e,"exp",(function(){return Xr})),n.d(e,"expandDims",(function(){return or})),n.d(e,"expm1",(function(){return Yr})),n.d(e,"eye",(function(){return Zs})),n.d(e,"fft",(function(){return qc})),n.d(e,"fill",(function(){return Vn})),n.d(e,"findBackend",(function(){return sn})),n.d(e,"findBackendFactory",(function(){return un})),n.d(e,"floor",(function(){return Jr})),n.d(e,"floorDiv",(function(){return xi})),n.d(e,"frame",(function(){return rl})),n.d(e,"fused",(function(){return jl})),n.d(e,"gather",(function(){return Ru})),n.d(e,"gatherND",(function(){return Yc})),n.d(e,"gather_util",(function(){return ji})),n.d(e,"getBackend",(function(){return an})),n.d(e,"getGradient",(function(){return g})),n.d(e,"getKernel",(function(){return m})),n.d(e,"getKernelsForBackend",(function(){return v})),n.d(e,"grad",(function(){return Yi})),n.d(e,"grads",(function(){return Ji})),n.d(e,"greater",(function(){return ku})),n.d(e,"greaterEqual",(function(){return _u})),n.d(e,"greaterEqualStrict",(function(){return Eu})),n.d(e,"greaterStrict",(function(){return Ou})),n.d(e,"hammingWindow",(function(){return nl})),n.d(e,"hannWindow",(function(){return el})),n.d(e,"ifft",(function(){return Hc})),n.d(e,"imag",(function(){return Tn})),n.d(e,"image",(function(){return Al})),n.d(e,"inTopKAsync",(function(){return ol})),n.d(e,"io",(function(){return Qf})),n.d(e,"irfft",(function(){return $c})),n.d(e,"isFinite",(function(){return ci})),n.d(e,"isInf",(function(){return ui})),n.d(e,"isNaN",(function(){return si})),n.d(e,"keep",(function(){return tn})),n.d(e,"leakyRelu",(function(){return Ic})),n.d(e,"less",(function(){return Su})),n.d(e,"lessEqual",(function(){return Cu})),n.d(e,"lessEqualStrict",(function(){return Au})),n.d(e,"lessStrict",(function(){return Nu})),n.d(e,"linalg",(function(){return wl})),n.d(e,"linspace",(function(){return qn})),n.d(e,"localResponseNormalization",(function(){return jc})),n.d(e,"log",(function(){return Zr})),n.d(e,"log1p",(function(){return Qr})),n.d(e,"logSigmoid",(function(){return ti})),n.d(e,"logSoftmax",(function(){return ia})),n.d(e,"logSumExp",(function(){return _c})),n.d(e,"logicalAnd",(function(){return qs})),n.d(e,"logicalNot",(function(){return Hs})),n.d(e,"logicalOr",(function(){return Gs})),n.d(e,"logicalXor",(function(){return $s})),n.d(e,"losses",(function(){return gl})),n.d(e,"matMul",(function(){return Ju})),n.d(e,"math",(function(){return ed})),n.d(e,"max",(function(){return Ec})),n.d(e,"maxPool",(function(){return sc})),n.d(e,"maxPool3d",(function(){return lc})),n.d(e,"maxPoolWithArgmax",(function(){return dc})),n.d(e,"maximum",(function(){return wi})),n.d(e,"maximumStrict",(function(){return ki})),n.d(e,"mean",(function(){return Oc})),n.d(e,"memory",(function(){return Ye})),n.d(e,"min",(function(){return Sc})),n.d(e,"minimum",(function(){return _i})),n.d(e,"minimumStrict",(function(){return Ei})),n.d(e,"mod",(function(){return Oi})),n.d(e,"modStrict",(function(){return Si})),n.d(e,"moments",(function(){return Cc})),n.d(e,"movingAverage",(function(){return Bc})),n.d(e,"mul",(function(){return Ci})),n.d(e,"mulStrict",(function(){return Ai})),n.d(e,"multiRNNCell",(function(){return zc})),n.d(e,"multinomial",(function(){return Qs})),n.d(e,"neg",(function(){return ei})),n.d(e,"nextFrame",(function(){return wd})),n.d(e,"norm",(function(){return Pc})),n.d(e,"notEqual",(function(){return Tu})),n.d(e,"notEqualStrict",(function(){return Iu})),n.d(e,"oneHot",(function(){return tu})),n.d(e,"ones",(function(){return Un})),n.d(e,"onesLike",(function(){return Gn})),n.d(e,"op",(function(){return Cn})),n.d(e,"outerProduct",(function(){return Qu})),n.d(e,"pad",(function(){return eu})),n.d(e,"pad1d",(function(){return nu})),n.d(e,"pad2d",(function(){return ru})),n.d(e,"pad3d",(function(){return iu})),n.d(e,"pad4d",(function(){return au})),n.d(e,"pool",(function(){return cc})),n.d(e,"pow",(function(){return Ni})),n.d(e,"powStrict",(function(){return Ti})),n.d(e,"prelu",(function(){return Dc})),n.d(e,"print",(function(){return er})),n.d(e,"prod",(function(){return Nc})),n.d(e,"profile",(function(){return Je})),n.d(e,"rand",(function(){return ou})),n.d(e,"randomGamma",(function(){return pu})),n.d(e,"randomNormal",(function(){return mu})),n.d(e,"randomUniform",(function(){return gu})),n.d(e,"range",(function(){return Hn})),n.d(e,"ready",(function(){return rn})),n.d(e,"real",(function(){return Nn})),n.d(e,"reciprocal",(function(){return ni})),n.d(e,"registerBackend",(function(){return cn})),n.d(e,"registerGradient",(function(){return b})),n.d(e,"registerKernel",(function(){return y})),n.d(e,"relu",(function(){return Mc})),n.d(e,"relu6",(function(){return Rc})),n.d(e,"removeBackend",(function(){return on})),n.d(e,"reshape",(function(){return sr})),n.d(e,"reverse",(function(){return tc})),n.d(e,"reverse1d",(function(){return ec})),n.d(e,"reverse2d",(function(){return nc})),n.d(e,"reverse3d",(function(){return rc})),n.d(e,"reverse4d",(function(){return ic})),n.d(e,"rfft",(function(){return Gc})),n.d(e,"round",(function(){return ri})),n.d(e,"rsqrt",(function(){return ii})),n.d(e,"scalar",(function(){return Mn})),n.d(e,"scatterND",(function(){return Vc})),n.d(e,"scatter_util",(function(){return Ui})),n.d(e,"selu",(function(){return Fc})),n.d(e,"separableConv2d",(function(){return Ku})),n.d(e,"serialization",(function(){return sd})),n.d(e,"setBackend",(function(){return nn})),n.d(e,"setPlatform",(function(){return fn})),n.d(e,"setdiff1dAsync",(function(){return dr})),n.d(e,"sigmoid",(function(){return ai})),n.d(e,"sign",(function(){return oi})),n.d(e,"signal",(function(){return al})),n.d(e,"sin",(function(){return li})),n.d(e,"sinh",(function(){return fi})),n.d(e,"slice",(function(){return hc})),n.d(e,"slice1d",(function(){return pc})),n.d(e,"slice2d",(function(){return mc})),n.d(e,"slice3d",(function(){return gc})),n.d(e,"slice4d",(function(){return vc})),n.d(e,"slice_util",(function(){return Xi})),n.d(e,"softmax",(function(){return ra})),n.d(e,"softplus",(function(){return di})),n.d(e,"spaceToBatchND",(function(){return ur})),n.d(e,"sparseToDense",(function(){return Xc})),n.d(e,"spectral",(function(){return Kc})),n.d(e,"split",(function(){return Qn})),n.d(e,"sqrt",(function(){return hi})),n.d(e,"square",(function(){return vu})),n.d(e,"squaredDifference",(function(){return yu})),n.d(e,"squaredDifferenceStrict",(function(){return Ii})),n.d(e,"squeeze",(function(){return cr})),n.d(e,"stack",(function(){return lr})),n.d(e,"step",(function(){return pi})),n.d(e,"stft",(function(){return il})),n.d(e,"stridedSlice",(function(){return Uc})),n.d(e,"sub",(function(){return Di})),n.d(e,"subStrict",(function(){return Mi})),n.d(e,"sum",(function(){return Ac})),n.d(e,"sumOutType",(function(){return It})),n.d(e,"tan",(function(){return mi})),n.d(e,"tanh",(function(){return gi})),n.d(e,"tensor",(function(){return In})),n.d(e,"tensor1d",(function(){return Rn})),n.d(e,"tensor2d",(function(){return Fn})),n.d(e,"tensor3d",(function(){return jn})),n.d(e,"tensor4d",(function(){return Pn})),n.d(e,"tensor5d",(function(){return Ln})),n.d(e,"tensor6d",(function(){return zn})),n.d(e,"tensor_util",(function(){return jt})),n.d(e,"test_util",(function(){return lu})),n.d(e,"tidy",(function(){return Ze})),n.d(e,"tile",(function(){return Js})),n.d(e,"time",(function(){return en})),n.d(e,"topk",(function(){return Wc})),n.d(e,"train",(function(){return bd})),n.d(e,"transpose",(function(){return aa})),n.d(e,"truncatedNormal",(function(){return bu})),n.d(e,"unregisterGradient",(function(){return w})),n.d(e,"unregisterKernel",(function(){return x})),n.d(e,"unsortedSegmentSum",(function(){return Fu})),n.d(e,"unstack",(function(){return fr})),n.d(e,"util",(function(){return dt})),n.d(e,"valueAndGrad",(function(){return Zi})),n.d(e,"valueAndGrads",(function(){return Qi})),n.d(e,"variable",(function(){return Bn})),n.d(e,"variableGrads",(function(){return ta})),n.d(e,"version_core",(function(){return ud})),n.d(e,"webgl",(function(){return cd})),n.d(e,"where",(function(){return Ks})),n.d(e,"whereAsync",(function(){return Xs})),n.d(e,"zeros",(function(){return Wn})),n.d(e,"zerosLike",(function(){return $n}));var o=function(t,e){return(o=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}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(o,s)}u((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var l=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.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,n,r=(e=this.global.location.search,n={},e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(n,e[0],e[1]),e.join("=")})),n);"tfjsflags"in r&&r.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 f(){return d}var d=null,h=new Map,p=new Map;function m(t,e){var n=k(t,e);return h.get(n)}function g(t){return p.get(t)}function v(t){for(var e=h.entries(),n=[];;){var r=e.next(),i=r.done,a=r.value;if(i)break;var o=a[0],s=a[1];o.split("_")[0]===t&&n.push(s)}return n}function y(t){var e=t.kernelName,n=t.backendName,r=k(e,n);if(h.has(r))throw new Error("The kernel '"+e+"' for backend '"+n+"' is already registered");h.set(r,t)}function b(t){var e=t.kernelName;p.has(e)&&console.warn("Overriding the gradient for '"+e+"'"),p.set(e,t)}function x(t,e){var n=k(t,e);if(!h.has(n))throw new Error("The kernel '"+t+"' for backend '"+e+"' is not registered");h.delete(n)}function w(t){if(!p.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");p.delete(t)}function k(t,e){return e+"_"+t}function _(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 E(t,e,n){return Math.max(t,Math.min(e,n))}function O(t){return t%2==0?t:t+1}function S(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return e}function C(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function A(t,e,n){void 0===n&&(n=""),C(D(t,e),(function(){return n+" Shapes "+t+" and "+e+" must match"}))}function N(t){C(null!=t,(function(){return"The input to the tensor constructor must be a non-null value."}))}function T(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||G(t)&&!n)for(var r=0;r<t.length;++r)T(t[r],e,n);else e.push(t);return e}function I(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++)e*=t[n];return e}function D(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 M(t){return t%1==0}function R(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 F(t){var e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function j(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function P(t,e,n){return void 0===e&&(e=function(t){return 0}),new Promise((function(r,i){var a=0,o=function(){if(t())r();else{var s=e(++a);null!=n&&a>=n?i():setTimeout(o,s)}};o()}))}function L(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 a=t.slice();return a[r]=e/n,a}function z(t,e){var n=e.length;return C((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})),C(t.every((function(t){return M(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 B(t,e){for(var n=[],r=[],i=null!=e&&Array.isArray(e)&&0===e.length,a=null==e||i?null:z(e,t).sort(),o=0,s=0;s<t.length;++s){if(null!=a){if(a[o]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==a[o]||a[o]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),a[o]<=s&&o++}1!==t[s]&&(n.push(t[s]),r.push(s))}return{newShape:n,keptDims:r}}function U(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 W(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 V(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 q(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function H(t,e){return!("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t)}function G(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array}function $(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 K(t){if(null==t)return 0;var e=0;return t.forEach((function(t){return e+=t.length})),e}function X(t){return"string"==typeof t||t instanceof String}function Y(t){return"boolean"==typeof t}function J(t){return"number"==typeof t}function Z(t){return Array.isArray(t)?Z(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":J(t)?"float32":X(t)?"string":Y(t)?"bool":"float32"}function Q(t){return!!(t&&t.constructor&&t.call&&t.apply)}function tt(t,e){for(var n=e;n<t;++n)if(t%n==0)return n;return t}function et(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 nt(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=T(t)),n&&V(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 rt(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 a=n[0],o=0;o<a;o++)i[o]=r[e+o];else{a=n[0];var s=n.slice(1),u=s.reduce((function(t,e){return t*e}));for(o=0;o<a;o++)i[o]=t(e+o*u,s,r)}return i}(0,t,e)}function it(t,e){for(var n=at(t,e),r=0;r<n.length;r++)n[r]=1;return n}function at(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 ot(){return f().platform.now()}function st(t){t.forEach((function(e){C(Number.isInteger(e)&&e>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+t+"]."}))}))}function ut(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.encode(t,e)}function ct(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.decode(t,e)}function lt(t,e,n){if(0===e)return 0;if(1===e)return t[0];for(var r=t[t.length-1],i=0;i<t.length-1;++i)r+=n[i]*t[i];return r}function ft(t,e,n){if(0===e)return[];if(1===e)return[t];for(var r=new Array(e),i=0;i<r.length-1;++i)r[i]=Math.floor(t/n[i]),t-=r[i]*n[i];return r[r.length-1]=t,r}var dt=Object.freeze({shuffle:_,clamp:E,nearestLargerEven:O,sum:S,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:C,assertShapesMatch:A,assertNonNull:N,flatten:T,sizeFromShape:I,isScalarShape:function(t){return 0===t.length},arraysEqual:D,isInt:M,tanh:R,sizeToSquarishShape:F,createShuffledIndices:function(t){for(var e=new Uint32Array(t),n=0;n<t;++n)e[n]=n;return _(e),e},rightPad:j,repeatedTry:P,inferFromImplicitShape:L,parseAxisParam:z,squeezeShape:B,getTypedArrayFromDType:U,getArrayFromDType:W,checkConversionForErrors:V,isValidDtype:q,hasEncodingLoss:H,isTypedArray:G,bytesPerElement:$,bytesFromStringArray:K,isString:X,isBoolean:Y,isNumber:J,inferDtype:Z,isFunction:Q,nearestDivisor:tt,computeStrides:et,toTypedArray:nt,toNestedArray:rt,makeOnesTypedArray:it,makeZerosTypedArray:at,now:ot,assertNonNegativeIntegerDimensions:st,fetch:function(t,e){return f().platform.fetch(t,e)},encodeString:ut,decodeString:ct,locToIndex:lt,indexToLoc:ft}),ht=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new pt)}return t.prototype.profileKernel=function(t,e,n){var r,i=this,a=this.backendTimer.time((function(){r=n()}));return r.forEach((function(n){n.data().then((function(r){!function(t,e,n){if("float32"!==e)return!1;for(var r=0;r<t.length;r++){var i=t[r];if(isNaN(i)||!isFinite(i))return console.warn("Found "+i+" in the result of '"+n+"'"),!0}}(r,n.dtype,t),a.then((function(a){var o="";null!=a.getExtraProfileInfo&&(o=a.getExtraProfileInfo()),i.logger.logKernelProfile(t,n,r,a.kernelMs,e,o)}))}))})),r},t}(),pt=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,i,a){var o="number"==typeof r?j(r+"ms",9):r.error,s=j(t,25),u=e.rank,c=e.size,l=j(e.shape.toString(),14),f="";for(var d in i){var h=i[d].shape||e.shape,p=h.length;f+=d+": "+p+"D "+(p>0?h:"")+" "}console.log("%c"+s+"\t%c"+o+"\t%c"+u+"D "+l+"\t%c"+c+"\t%c"+f+"\t%c"+a,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},t}();function mt(t,e,n){return j(Array.isArray(t)?parseFloat(t[0].toFixed(7))+" + "+parseFloat(t[1].toFixed(7))+"j":X(t)?"'"+t+"'":"bool"===n?gt(t):parseFloat(t.toFixed(7)).toString(),e)}function gt(t){return 0===t?"false":"true"}function vt(t){for(var e=[],n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}var yt=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=I(t),null!=n){var i=n.length;C(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||W(e,this.size),this.strides=et(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]),C(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 a=i[r];if(a<0||a>=this.shape[n]){var o="Requested out of range element at "+t+". Buffer shape="+this.shape;throw new Error(o)}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 bt().makeTensor(this.values,this.shape,this.dtype)},t}(),bt=null,xt=null,wt=null,kt=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=I(t),this.strides=et(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}return t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D()},t.prototype.asScalar=function(){return this.throwIfDisposed(),C(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(),xt.cast(this,t)},Object.defineProperty(t.prototype,"rank",{get:function(){return this.shape.length},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,xt.buffer(this.shape,this.dtype,t)]}}))}))},t.prototype.bufferSync=function(){return xt.buffer(this.shape,this.dtype,this.dataSync())},t.prototype.array=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,this.data()];case 1:return t=e.sent(),[2,rt(this.shape,t)]}}))}))},t.prototype.arraySync=function(){return rt(this.shape,this.dataSync())},t.prototype.data=function(){return u(this,void 0,void 0,(function(){var t,e;return c(this,(function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=bt().read(this.dataId),"string"!==this.dtype?[3,2]:[4,t];case 1:e=n.sent();try{return[2,e.map((function(t){return ct(t)}))]}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}n.label=2;case 2:return[2,t]}}))}))},t.prototype.dataSync=function(){this.throwIfDisposed();var t=bt().readSync(this.dataId);if("string"===this.dtype)try{return t.map((function(t){return ct(t)}))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t},t.prototype.bytes=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,bt().read(this.dataId)];case 1:return t=e.sent(),"string"===this.dtype?[2,t]:[2,new Uint8Array(t.buffer)]}}))}))},t.prototype.dispose=function(){this.isDisposed||(bt().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),xt.print(this,t)},t.prototype.reshape=function(t){return this.throwIfDisposed(),xt.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),xt.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),xt.cumsum(this,t,e,n)},t.prototype.squeeze=function(t){return this.throwIfDisposed(),xt.squeeze(this,t)},t.prototype.clone=function(){return this.throwIfDisposed(),xt.clone(this)},t.prototype.toString=function(t){return void 0===t&&(t=!1),function(t,e,n,r){var i=et(e),a=function(t,e,n,r){var i=I(e),a=r[r.length-1],o=new Array(a).fill(0),s=e.length,u="complex64"===n?vt(t):t;if(s>1)for(var c=0;c<i/a;c++)for(var l=c*a,f=0;f<a;f++)o[f]=Math.max(o[f],mt(u[l+f],0,n).length);return o}(t,e,n,i),o=e.length,s=function t(e,n,r,i,a,o){void 0===o&&(o=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return"complex64"===r?[mt(vt(e)[0],0,r)]:"bool"===r?[gt(e[0])]:[e[0].toString()];if(1===c){if(u>20){var l=3*s,f=Array.from(e.slice(0,l)),d=Array.from(e.slice((u-3)*s,u*s));return"complex64"===r&&(f=vt(f),d=vt(d)),["["+f.map((function(t,e){return mt(t,a[e],r)})).join(", ")+", ..., "+d.map((function(t,e){return mt(t,a[u-3+e],r)})).join(", ")+"]"]}return["["+("complex64"===r?vt(e):Array.from(e)).map((function(t,e){return mt(t,a[e],r)})).join(", ")+"]"]}var h=n.slice(1),p=i.slice(1),m=i[0]*s,g=[];if(u>20){for(var v=0;v<3;v++){var y=(b=v*m)+m;g.push.apply(g,t(e.slice(b,y),h,r,p,a,!1))}for(g.push("..."),v=u-3;v<u;v++)y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),h,r,p,a,v===u-1))}else for(v=0;v<u;v++){var b;y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),h,r,p,a,v===u-1))}var x=2===c?",":"";for(g[0]="["+g[0]+x,v=1;v<g.length-1;v++)g[v]=" "+g[v]+x;var w=",\n";for(v=2;v<c;v++)w+="\n";return g[g.length-1]=" "+g[g.length-1]+"]"+(o?"":w),g}(t,e,n,i,a),u=["Tensor"];return r&&(u.push(" dtype: "+n),u.push(" rank: "+o),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.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),xt.gather(this,t,e)},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),xt.matMul(this,t,e,n)},t.prototype.dot=function(t){return this.throwIfDisposed(),xt.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(),xt.norm(this,t,e,n)},t.prototype.slice=function(t,e){return this.throwIfDisposed(),xt.slice(this,t,e)},t.prototype.reverse=function(t){return this.throwIfDisposed(),xt.reverse(this,t)},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),xt.concat([this].concat(e),n)},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),xt.split(this,t,e)},t.prototype.stack=function(t,e){return void 0===e&&(e=0),xt.stack([this,t],e)},t.prototype.unstack=function(t){return void 0===t&&(t=0),xt.unstack(this,t)},t.prototype.batchNormalization=function(t,e,n,r,i){return void 0===n&&(n=.001),wt("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.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.all(this,t,e)},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.any(this,t,e)},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.logSumExp(this,t,e)},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.sum(this,t,e)},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.prod(this,t,e)},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.mean(this,t,e)},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.min(this,t,e)},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),xt.max(this,t,e)},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),xt.argMin(this,t)},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),xt.argMax(this,t)},t.prototype.cast=function(t){return this.throwIfDisposed(),xt.cast(this,t)},t.prototype.addStrict=function(t){return this.throwIfDisposed(),xt.addStrict(this,t)},t.prototype.atan2=function(t){return this.throwIfDisposed(),xt.atan2(this,t)},t.prototype.sub=function(t){return this.throwIfDisposed(),xt.sub(this,t)},t.prototype.subStrict=function(t){return this.throwIfDisposed(),xt.subStrict(this,t)},t.prototype.pow=function(t){return this.throwIfDisposed(),xt.pow(this,t)},t.prototype.powStrict=function(t){return this.throwIfDisposed(),xt.powStrict(this,t)},t.prototype.mul=function(t){return this.throwIfDisposed(),xt.mul(this,t)},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),xt.mulStrict(this,t)},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),xt.floorDiv(this,t)},t.prototype.divStrict=function(t){return this.throwIfDisposed(),xt.divStrict(this,t)},t.prototype.minimum=function(t){return this.throwIfDisposed(),xt.minimum(this,t)},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),xt.minimumStrict(this,t)},t.prototype.maximum=function(t){return this.throwIfDisposed(),xt.maximum(this,t)},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),xt.maximumStrict(this,t)},t.prototype.mod=function(t){return this.throwIfDisposed(),xt.mod(this,t)},t.prototype.modStrict=function(t){return this.throwIfDisposed(),xt.modStrict(this,t)},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),xt.squaredDifferenceStrict(this,t)},t.prototype.notEqual=function(t){return this.throwIfDisposed(),xt.notEqual(this,t)},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),xt.notEqualStrict(this,t)},t.prototype.less=function(t){return this.throwIfDisposed(),xt.less(this,t)},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),xt.lessStrict(this,t)},t.prototype.equal=function(t){return this.throwIfDisposed(),xt.equal(this,t)},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),xt.equalStrict(this,t)},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),xt.lessEqual(this,t)},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),xt.lessEqualStrict(this,t)},t.prototype.greater=function(t){return this.throwIfDisposed(),xt.greater(this,t)},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),xt.greaterStrict(this,t)},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),xt.greaterEqual(this,t)},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),xt.greaterEqualStrict(this,t)},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),xt.logicalAnd(this,t)},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),xt.logicalOr(this,t)},t.prototype.logicalNot=function(){return this.throwIfDisposed(),xt.logicalNot(this)},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),xt.logicalXor(this,t)},t.prototype.where=function(t,e){return this.throwIfDisposed(),xt.where(t,this,e)},t.prototype.neg=function(){return this.throwIfDisposed(),xt.neg(this)},t.prototype.ceil=function(){return this.throwIfDisposed(),xt.ceil(this)},t.prototype.floor=function(){return this.throwIfDisposed(),xt.floor(this)},t.prototype.sign=function(){return this.throwIfDisposed(),xt.sign(this)},t.prototype.isNaN=function(){return this.throwIfDisposed(),xt.isNaN(this)},t.prototype.isInf=function(){return this.throwIfDisposed(),xt.isInf(this)},t.prototype.isFinite=function(){return this.throwIfDisposed(),xt.isFinite(this)},t.prototype.exp=function(){return this.throwIfDisposed(),xt.exp(this)},t.prototype.expm1=function(){return this.throwIfDisposed(),xt.expm1(this)},t.prototype.log=function(){return this.throwIfDisposed(),xt.log(this)},t.prototype.log1p=function(){return this.throwIfDisposed(),xt.log1p(this)},t.prototype.sqrt=function(){return this.throwIfDisposed(),xt.sqrt(this)},t.prototype.rsqrt=function(){return this.throwIfDisposed(),xt.rsqrt(this)},t.prototype.square=function(){return this.throwIfDisposed(),xt.square(this)},t.prototype.reciprocal=function(){return this.throwIfDisposed(),xt.reciprocal(this)},t.prototype.abs=function(){return this.throwIfDisposed(),xt.abs(this)},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),xt.clipByValue(this,t,e)},t.prototype.relu=function(){return this.throwIfDisposed(),xt.relu(this)},t.prototype.relu6=function(){return this.throwIfDisposed(),xt.relu6(this)},t.prototype.elu=function(){return this.throwIfDisposed(),xt.elu(this)},t.prototype.selu=function(){return this.throwIfDisposed(),xt.selu(this)},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),xt.leakyRelu(this,t)},t.prototype.prelu=function(t){return this.throwIfDisposed(),xt.prelu(this,t)},t.prototype.sigmoid=function(){return this.throwIfDisposed(),xt.sigmoid(this)},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),xt.logSigmoid(this)},t.prototype.softplus=function(){return this.throwIfDisposed(),xt.softplus(this)},t.prototype.zerosLike=function(){return this.throwIfDisposed(),xt.zerosLike(this)},t.prototype.onesLike=function(){return this.throwIfDisposed(),xt.onesLike(this)},t.prototype.sin=function(){return this.throwIfDisposed(),xt.sin(this)},t.prototype.cos=function(){return this.throwIfDisposed(),xt.cos(this)},t.prototype.tan=function(){return this.throwIfDisposed(),xt.tan(this)},t.prototype.asin=function(){return this.throwIfDisposed(),xt.asin(this)},t.prototype.acos=function(){return this.throwIfDisposed(),xt.acos(this)},t.prototype.atan=function(){return this.throwIfDisposed(),xt.atan(this)},t.prototype.sinh=function(){return this.throwIfDisposed(),xt.sinh(this)},t.prototype.cosh=function(){return this.throwIfDisposed(),xt.cosh(this)},t.prototype.tanh=function(){return this.throwIfDisposed(),xt.tanh(this)},t.prototype.asinh=function(){return this.throwIfDisposed(),xt.asinh(this)},t.prototype.acosh=function(){return this.throwIfDisposed(),xt.acosh(this)},t.prototype.atanh=function(){return this.throwIfDisposed(),xt.atanh(this)},t.prototype.erf=function(){return this.throwIfDisposed(),xt.erf(this)},t.prototype.round=function(){return this.throwIfDisposed(),xt.round(this)},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),xt.step(this,t)},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),xt.softmax(this,t)},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),xt.logSoftmax(this,t)},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),xt.image.resizeBilinear(this,t,e)},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),xt.image.resizeNearestNeighbor(this,t,e)},t.prototype.conv1d=function(t,e,n,r,i,a){return void 0===r&&(r="NWC"),void 0===i&&(i=1),this.throwIfDisposed(),xt.conv1d(this,t,e,n,r,i,a)},t.prototype.conv2d=function(t,e,n,r,i,a){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),xt.conv2d(this,t,e,n,r,i,a)},t.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),xt.conv2dTranspose(this,t,e,n,r,i)},t.prototype.depthwiseConv2D=function(t,e,n,r,i,a){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),xt.depthwiseConv2d(this,t,e,n,r,i,a)},t.prototype.separableConv2d=function(t,e,n,r,i,a){return void 0===i&&(i=[1,1]),void 0===a&&(a="NHWC"),this.throwIfDisposed(),xt.separableConv2d(this,t,e,n,r,i,a)},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),xt.avgPool(this,t,e,n,r)},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),xt.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),xt.localResponseNormalization(this,t,e,n,r)},t.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),xt.pool(this,t,e,n,r,i)},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),bt().makeVariable(this,t,e,n)},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),xt.unsortedSegmentSum(this,t,e)},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),xt.batchToSpaceND(this,t,e)},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),xt.spaceToBatchND(this,t,e)},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),xt.topk(this,t,e)},t.prototype.stridedSlice=function(t,e,n,r,i,a,o,s){return void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===s&&(s=0),this.throwIfDisposed(),xt.stridedSlice(this,t,e,n,r,i,a,o,s)},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),xt.depthToSpace(this,t,e)},t.prototype.fft=function(){return this.throwIfDisposed(),xt.spectral.fft(this)},t.prototype.ifft=function(){return this.throwIfDisposed(),xt.spectral.ifft(this)},t.prototype.rfft=function(){return this.throwIfDisposed(),xt.spectral.rfft(this)},t.prototype.irfft=function(){return this.throwIfDisposed(),xt.spectral.irfft(this)},t}();Object.defineProperty(kt,Symbol.hasInstance,{value:function(t){return!!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype}});var _t,Et,Ot,St,Ct,At=function(t){function e(e,n,r,i){var a=t.call(this,e.shape,e.dtype,e.dataId,i)||this;return a.trainable=n,a.name=r,a}return s(e,t),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(!D(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");bt().disposeTensor(this),this.dataId=t.dataId,bt().incRef(this,null)},e.prototype.dispose=function(){bt().disposeVariable(this),this.isDisposedInternal=!0},e}(kt);Object.defineProperty(At,Symbol.hasInstance,{value:function(t){return t instanceof kt&&null!=t.assign&&t.assign instanceof Function}}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(_t||(_t={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(Et||(Et={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(Ot||(Ot={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(St||(St={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(Ct||(Ct={}));var Nt={float32:St,int32:Et,bool:Ot,complex64:Ct};function Tt(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error("Can not upcast "+t+" with "+e)}return Nt[t][e]}function It(t){return Tt(t,"int32")}function Dt(t,e){if(t.dtype===e.dtype)return[t,e];var n=Tt(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Mt(t,e){C(t.dtype===e.dtype,(function(){return"The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match"}))}function Rt(t){var e=[];return function t(e,n,r){if(null!=e)if(e instanceof kt)n.push(e);else if(i=e,Array.isArray(i)||"object"==typeof i){var i,a=e;for(var o in a){var s=a[o];r.has(s)||(r.add(s),t(s,n,r))}}}(t,e,new Set),e}var Ft,jt=Object.freeze({makeTypesMatch:Dt,assertTypesMatch:Mt,isTensorInList:function(t,e){return e.some((function(e){return e.id===t.id}))},getTensorsInContainer:Rt}),Pt=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.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1