diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7a7bb15 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..887bd4e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 José M. Moreno (https://github.com/josemmo) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc97c93 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Hotdog or Not Hotdog +![Lighthouse PWA: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=PWA) +![Lighthouse Performance: 93/100](https://lighthouse-badge.appspot.com/?score=93&category=Perf) + +Yet another sample project using [TensorFlow.js](https://js.tensorflow.js/) and MobileNet to create a Progressive Web App (PWA) which recognizes Hotdogs and Not Hotdogs, as shown in the HBO series' Silicon Valley. + +[![View video](https://img.youtube.com/vi/ACmydtFDTGs/mqdefault.jpg)](https://www.youtube.com/watch?v=ACmydtFDTGs) + +## License +This project in under the MIT License. You can freely do whatever you want with its code as long as you credit the author. diff --git a/app.css b/app.css new file mode 100644 index 0000000..ad392d0 --- /dev/null +++ b/app.css @@ -0,0 +1,98 @@ +/* COMMON */ +@font-face { + font-family: 'Roboto'; + font-style: normal; + font-weight: 900; + src: url('roboto-black.ttf') format('truetype'); +} +body, button { + font-family: 'Roboto', sans-serif; + font-weight: 900; +} +body { background: #202020 } +* { user-select: none } + + +/* CAMERA */ +#camera { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + object-fit: cover; + z-index: 1; +} + + +/* OVERLAY */ +#overlay { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + z-index: 2; +} + +#overlay .dialog { + position: absolute; + left: 30px; + right: 30px; + top: 50%; + transform: translateY(-50%); + padding: 30px; + background: #21a8c6; + color: #fff; + border: solid 2px; + border-radius: 8px; + text-align: center; + font-size: 18px; +} + +#overlay .result { + position: absolute; + left: 0; + right: 0; + top: 0; + padding: 15px 0; + color: #ff0; + -webkit-text-stroke: 1.7px #000; + filter: drop-shadow(-2px 1px 0 #fff) drop-shadow(2px 1px 0 #fff); + text-align: center; + font-size: 40px; + display: none; +} +#overlay .result::after { + content: ''; + box-sizing: border-box; + position: absolute; + top: calc(100% - 20px); + left: 50%; + margin-left: -50px; + width: 100px; + height: 100px; + background: url('images/hotdog.png') no-repeat center; + background-size: 80%; + border-radius: 50%; + z-index: -1; +} +#overlay .result.hotdog, +#overlay .result.hotdog::after { + background-color: #0f0; +} +#overlay .result.not-hotdog, +#overlay .result.not-hotdog::after { + background-color: #f00; +} +#overlay .result.not-hotdog::before { + content: ''; + position: absolute; + top: calc(100% - 20px); + left: 50%; + margin-left: -50px; + width: 100px; + height: 100px; + background: url('images/cross.png') no-repeat center; + background-size: 70%; +} diff --git a/app.js b/app.js new file mode 100644 index 0000000..5215cbb --- /dev/null +++ b/app.js @@ -0,0 +1,214 @@ +(function() { + + var MODEL_PATH = 'model/mobilenet.json'; + var CLASSES_PATH = 'model/mobilenet.classes.json'; + var IMAGE_SIZE = 224; // Required by this model + var PREDICT_INTERVAL = 1000; // Delay between predictions in milliseconds + var MAX_CLASSES = 8; + + var overlayDialog = document.querySelector('#overlay .dialog'); + var camera = document.getElementById('camera'); + var notification = new Audio('notification.ogg'); + notification.preload = 'auto'; + + var model, modelClasses; + var lastCheck = null; + + + /** + * Update UI + * @param {Boolean} isHotdog Is hotdog + */ + function updateUI(isHotdog) { + if (lastCheck == isHotdog) return; + + // Update result overlay + var result = document.querySelector('#overlay .result'); + if (isHotdog) { + result.classList.remove('not-hotdog'); + result.classList.add('hotdog'); + result.innerHTML = 'Hotdog!'; + + // Play sound + notification.play(); + } else { + result.classList.remove('hotdog'); + result.classList.add('not-hotdog'); + result.innerHTML = 'Not Hotdog!'; + } + result.style.display = 'block'; + + // Update last state + lastCheck = isHotdog; + } + + + /** + * Get camera image + * @return {HTMLCanvasElement} Canvas with image + */ + function getCameraImage() { + var c = document.createElement('canvas'); + c.width = IMAGE_SIZE; + c.height = IMAGE_SIZE; + c.getContext('2d').drawImage(camera, 0, 0, c.width, c.height); + return c; + } + + + /** + * Connect to camera + * @async + * @return {Promise} Callback + */ + function connectToCamera() { + return new Promise(function(resolve, reject) { + navigator.mediaDevices.getUserMedia({ + video: { + facingMode: 'environment' // For phones, prefer main camera + } + }).then(function(stream) { + // Start rendering camera + var streamURL = window.URL.createObjectURL(stream); + try { + camera.srcObject = streamURL; + } catch (e) { + camera.src = streamURL; + } + + // Resolve promise + resolve(); + }).catch(reject); + }); + } + + + /** + * Load model + * @async + * @return {Promise} Callback + */ + function loadModel() { + return new Promise(function(resolve, reject) { + tf.loadModel(MODEL_PATH).then(function(m) { + model = m; + fetch(CLASSES_PATH).then(function(res) { + res.json().then(function(json) { + modelClasses = json; + resolve(); + }); + }); + }).catch(reject); + }); + } + + + /** + * Start predicting + */ + function startPredicting() { + predict().then(function(isHotdog) { + // Update UI + if (isHotdog) console.log('Hotdog found!'); + updateUI(isHotdog); + + // Schedule next prediction + setTimeout(function() { + startPredicting(); + }, PREDICT_INTERVAL); + }); + } + + + /** + * Predict + * @async + * @return {Promise} Is hotdog + */ + function predict() { + return new Promise(function(resolve, reject) { + tf.tidy(function() { + // Get camera pixels and covert them to a tensor + var image = tf.fromPixels(getCameraImage()).toFloat(); + + // Change coordinates from [0,255] to [-1,1] + var offset = tf.scalar(127.5); + image = image.sub(offset).div(offset); + + // Convert linear array to matrix + image = image.reshape([1, IMAGE_SIZE, IMAGE_SIZE, 3]); + + // Make a prediction using loaded model + var logits = model.predict(image); + getTopClasses(logits, MAX_CLASSES).then(function(classes) { + console.log('Found classes', classes); + + // Validate whether is Hotdog or Not Hotdog + var isHotdog = false; + for (var i=0; i -1) { + isHotdog = true; + break; + } + } + resolve(isHotdog); + }); + }); + }); + } + + + /** + * Get top classes + * @param {tf.Tensor} logits Logits returned by model + * @param {Integer} maxClasses Maximum number of classes to return + * @return {Promise} Top classes + */ + function getTopClasses(logits, maxClasses) { + return new Promise(function(resolve, reject) { + // Get raw data from logits + logits.data().then(function(values) { + // Sort data by value, while keeping index + var sortedData = []; + for (var i=0; i + + + + + Hotdog or Not Hotdog + + + + + + + +
+
+
Concede acceso a la cámara para continuar
+
+ + + + + + + + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..d81173f --- /dev/null +++ b/manifest.json @@ -0,0 +1,26 @@ +{ + "name": "Hotdog or Not Hotdog", + "short_name": "Not Hotdog", + "description": "Detecta perritos calientes mediante el uso de IA", + "icons": [ + { + "src": "images/icon-48.png", + "type": "image/png", + "sizes": "48x48" + }, + { + "src": "images/icon-144.png", + "type": "image/png", + "sizes": "144x144" + }, + { + "src": "images/icon-512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": "./", + "display": "standalone", + "background_color": "#202020", + "theme_color": "#21a8c6" +} diff --git a/model/group1-shard1of1 b/model/group1-shard1of1 new file mode 100644 index 0000000..bd51711 Binary files /dev/null and b/model/group1-shard1of1 differ diff --git a/model/group10-shard1of1 b/model/group10-shard1of1 new file mode 100644 index 0000000..be70b8e Binary files /dev/null and b/model/group10-shard1of1 differ diff --git a/model/group11-shard1of1 b/model/group11-shard1of1 new file mode 100644 index 0000000..563207c Binary files /dev/null and b/model/group11-shard1of1 differ diff --git a/model/group12-shard1of1 b/model/group12-shard1of1 new file mode 100644 index 0000000..51b380b --- /dev/null +++ b/model/group12-shard1of1 @@ -0,0 +1,2 @@ +#?C>/=&?-H?@c@?֦@\r@R@-;ABX~M,({'D¢90BBu>cJkC1 +ENB \ No newline at end of file diff --git a/model/group13-shard1of1 b/model/group13-shard1of1 new file mode 100644 index 0000000..b09e1f7 --- /dev/null +++ b/model/group13-shard1of1 @@ -0,0 +1,7 @@ +hT?)˿t#M7u?1><ѵW?~?I2?f/҈?O>s鑿*i@z@×? )* @ǀh?I@N!@QY@d@ِj@*}*;/q@ ?:큾qU>?@ +AskV%>e m>iE u6f?a ݛ'@@(= .~> +ǩIDŽGEmQ@Ҷ?{?G7? @ A'_@P0?E?4TA+="@ P=~>e=ʽFA?*e +@D@* @5ǿo]@7I=E>䅱?(s @ڽh_?b?;3EZ=/>0SWAAJ +P? +?:-? B??@?o<,1? +1.kR?ki&:D?2%@ˑ@CÿFA@դ'&R?a)X#࿖1?SYRV? 5j@3 \ No newline at end of file diff --git a/model/group14-shard1of1 b/model/group14-shard1of1 new file mode 100644 index 0000000..e44f706 Binary files /dev/null and b/model/group14-shard1of1 differ diff --git a/model/group15-shard1of1 b/model/group15-shard1of1 new file mode 100644 index 0000000..4ea0bad Binary files /dev/null and b/model/group15-shard1of1 differ diff --git a/model/group16-shard1of1 b/model/group16-shard1of1 new file mode 100644 index 0000000..24e2f17 Binary files /dev/null and b/model/group16-shard1of1 differ diff --git a/model/group17-shard1of1 b/model/group17-shard1of1 new file mode 100644 index 0000000..44af369 Binary files /dev/null and b/model/group17-shard1of1 differ diff --git a/model/group18-shard1of1 b/model/group18-shard1of1 new file mode 100644 index 0000000..c5154bc --- /dev/null +++ b/model/group18-shard1of1 @@ -0,0 +1,2 @@ +&b?b?sN?m?<W?8F???Њ|?.P?r/]?_Q=?C/T?T?/>}?3@@@h?u@Ll?M@@$)0x? @vE@?L{?^?-@ @$@;G=Wt??^Z?oL?R@>?qw&A@]5@,*A7uA.A]AM1@24Ak A@KAMA0B:AA%@n+A9>W>@|B@@@Ss?AB6BjWB,BAB8@B4ABhBB BVB` CB_oVB->_B(CbC7B|BsC4A@A0BB#B^CA!B7>#&ABB \ No newline at end of file diff --git a/model/group19-shard1of1 b/model/group19-shard1of1 new file mode 100644 index 0000000..775d03b Binary files /dev/null and b/model/group19-shard1of1 differ diff --git a/model/group2-shard1of1 b/model/group2-shard1of1 new file mode 100644 index 0000000..f30b366 --- /dev/null +++ b/model/group2-shard1of1 @@ -0,0 +1,4 @@ +> +T +̆?0?@#GQA>u?@=@s>8ǾV&@v@uF@: B?ȭ[Q9ye<_+8=}<*@$@U5 +F8@\3= (@D5 \ No newline at end of file diff --git a/model/group20-shard1of1 b/model/group20-shard1of1 new file mode 100644 index 0000000..4b2809c Binary files /dev/null and b/model/group20-shard1of1 differ diff --git a/model/group21-shard1of1 b/model/group21-shard1of1 new file mode 100644 index 0000000..8e708b0 Binary files /dev/null and b/model/group21-shard1of1 differ diff --git a/model/group22-shard1of1 b/model/group22-shard1of1 new file mode 100644 index 0000000..0703fc1 Binary files /dev/null and b/model/group22-shard1of1 differ diff --git a/model/group23-shard1of1 b/model/group23-shard1of1 new file mode 100644 index 0000000..7f5b536 Binary files /dev/null and b/model/group23-shard1of1 differ diff --git a/model/group24-shard1of1 b/model/group24-shard1of1 new file mode 100644 index 0000000..27a0a62 Binary files /dev/null and b/model/group24-shard1of1 differ diff --git a/model/group25-shard1of1 b/model/group25-shard1of1 new file mode 100644 index 0000000..5b8e707 Binary files /dev/null and b/model/group25-shard1of1 differ diff --git a/model/group26-shard1of1 b/model/group26-shard1of1 new file mode 100644 index 0000000..6cb4195 Binary files /dev/null and b/model/group26-shard1of1 differ diff --git a/model/group27-shard1of1 b/model/group27-shard1of1 new file mode 100644 index 0000000..ca8c664 Binary files /dev/null and b/model/group27-shard1of1 differ diff --git a/model/group28-shard1of1 b/model/group28-shard1of1 new file mode 100644 index 0000000..daaad27 Binary files /dev/null and b/model/group28-shard1of1 differ diff --git a/model/group29-shard1of1 b/model/group29-shard1of1 new file mode 100644 index 0000000..7b6183e Binary files /dev/null and b/model/group29-shard1of1 differ diff --git a/model/group3-shard1of1 b/model/group3-shard1of1 new file mode 100644 index 0000000..53b16cf Binary files /dev/null and b/model/group3-shard1of1 differ diff --git a/model/group30-shard1of1 b/model/group30-shard1of1 new file mode 100644 index 0000000..b2e2a50 Binary files /dev/null and b/model/group30-shard1of1 differ diff --git a/model/group31-shard1of1 b/model/group31-shard1of1 new file mode 100644 index 0000000..16d6bfe Binary files /dev/null and b/model/group31-shard1of1 differ diff --git a/model/group32-shard1of1 b/model/group32-shard1of1 new file mode 100644 index 0000000..d421186 Binary files /dev/null and b/model/group32-shard1of1 differ diff --git a/model/group33-shard1of1 b/model/group33-shard1of1 new file mode 100644 index 0000000..c36c071 Binary files /dev/null and b/model/group33-shard1of1 differ diff --git a/model/group34-shard1of1 b/model/group34-shard1of1 new file mode 100644 index 0000000..cb85b68 Binary files /dev/null and b/model/group34-shard1of1 differ diff --git a/model/group35-shard1of1 b/model/group35-shard1of1 new file mode 100644 index 0000000..eb69357 Binary files /dev/null and b/model/group35-shard1of1 differ diff --git a/model/group36-shard1of1 b/model/group36-shard1of1 new file mode 100644 index 0000000..817344e Binary files /dev/null and b/model/group36-shard1of1 differ diff --git a/model/group37-shard1of1 b/model/group37-shard1of1 new file mode 100644 index 0000000..ecd1d91 Binary files /dev/null and b/model/group37-shard1of1 differ diff --git a/model/group38-shard1of1 b/model/group38-shard1of1 new file mode 100644 index 0000000..2e0262b Binary files /dev/null and b/model/group38-shard1of1 differ diff --git a/model/group39-shard1of1 b/model/group39-shard1of1 new file mode 100644 index 0000000..e347328 Binary files /dev/null and b/model/group39-shard1of1 differ diff --git a/model/group4-shard1of1 b/model/group4-shard1of1 new file mode 100644 index 0000000..f89910b Binary files /dev/null and b/model/group4-shard1of1 differ diff --git a/model/group40-shard1of1 b/model/group40-shard1of1 new file mode 100644 index 0000000..8cd80f1 Binary files /dev/null and b/model/group40-shard1of1 differ diff --git a/model/group41-shard1of1 b/model/group41-shard1of1 new file mode 100644 index 0000000..4eb76b2 --- /dev/null +++ b/model/group41-shard1of1 @@ -0,0 +1,5 @@ +">̥!?⿄?D@0@9>d?]e?b?PM?NW?~?u?H.>IN??,Y?:r> ?}2?~?>dI?S?X@5?(?/:?>%?1.?q@i,`V@r?=@4j@:@^>1@*@%@C4@o?G$@{=@|(@.m?Fh@9@5?? +?$b@T8Q@/Y?5U?2@?t8@v>|z@ +DՓ@YKw@H))&/3[v6D e@p\hqϾJ6=1_?H*@%TJ@v!AUk* +?r=ֿ +y?2?Qn@J#?٭g>ip?2@?e?SD?E??wA??&?Usuxi@~?[?A\[>:-@4N>/? ? ?no7?G1?1c?>(A7??BE@@ \ No newline at end of file diff --git a/model/group42-shard1of1 b/model/group42-shard1of1 new file mode 100644 index 0000000..87e3894 Binary files /dev/null and b/model/group42-shard1of1 differ diff --git a/model/group43-shard1of1 b/model/group43-shard1of1 new file mode 100644 index 0000000..2b8a213 Binary files /dev/null and b/model/group43-shard1of1 differ diff --git a/model/group44-shard1of1 b/model/group44-shard1of1 new file mode 100644 index 0000000..d022176 Binary files /dev/null and b/model/group44-shard1of1 differ diff --git a/model/group45-shard1of1 b/model/group45-shard1of1 new file mode 100644 index 0000000..dfe4da8 Binary files /dev/null and b/model/group45-shard1of1 differ diff --git a/model/group46-shard1of1 b/model/group46-shard1of1 new file mode 100644 index 0000000..1640dd8 Binary files /dev/null and b/model/group46-shard1of1 differ diff --git a/model/group47-shard1of1 b/model/group47-shard1of1 new file mode 100644 index 0000000..a03d04d Binary files /dev/null and b/model/group47-shard1of1 differ diff --git a/model/group48-shard1of1 b/model/group48-shard1of1 new file mode 100644 index 0000000..15b3ae9 Binary files /dev/null and b/model/group48-shard1of1 differ diff --git a/model/group49-shard1of1 b/model/group49-shard1of1 new file mode 100644 index 0000000..43cd606 Binary files /dev/null and b/model/group49-shard1of1 differ diff --git a/model/group5-shard1of1 b/model/group5-shard1of1 new file mode 100644 index 0000000..bd227b0 Binary files /dev/null and b/model/group5-shard1of1 differ diff --git a/model/group50-shard1of1 b/model/group50-shard1of1 new file mode 100644 index 0000000..fe1b4a6 Binary files /dev/null and b/model/group50-shard1of1 differ diff --git a/model/group51-shard1of1 b/model/group51-shard1of1 new file mode 100644 index 0000000..cfe87a6 Binary files /dev/null and b/model/group51-shard1of1 differ diff --git a/model/group52-shard1of1 b/model/group52-shard1of1 new file mode 100644 index 0000000..5d34e33 Binary files /dev/null and b/model/group52-shard1of1 differ diff --git a/model/group53-shard1of1 b/model/group53-shard1of1 new file mode 100644 index 0000000..36abaef Binary files /dev/null and b/model/group53-shard1of1 differ diff --git a/model/group54-shard1of1 b/model/group54-shard1of1 new file mode 100644 index 0000000..c496eb1 Binary files /dev/null and b/model/group54-shard1of1 differ diff --git a/model/group55-shard1of1 b/model/group55-shard1of1 new file mode 100644 index 0000000..b9d8357 Binary files /dev/null and b/model/group55-shard1of1 differ diff --git a/model/group6-shard1of1 b/model/group6-shard1of1 new file mode 100644 index 0000000..4231264 Binary files /dev/null and b/model/group6-shard1of1 differ diff --git a/model/group7-shard1of1 b/model/group7-shard1of1 new file mode 100644 index 0000000..763abe2 Binary files /dev/null and b/model/group7-shard1of1 differ diff --git a/model/group8-shard1of1 b/model/group8-shard1of1 new file mode 100644 index 0000000..52bc94d Binary files /dev/null and b/model/group8-shard1of1 differ diff --git a/model/group9-shard1of1 b/model/group9-shard1of1 new file mode 100644 index 0000000..727443f Binary files /dev/null and b/model/group9-shard1of1 differ diff --git a/model/mobilenet.classes.json b/model/mobilenet.classes.json new file mode 100644 index 0000000..8bdcfc8 --- /dev/null +++ b/model/mobilenet.classes.json @@ -0,0 +1 @@ +{"0":"tench, Tinca tinca","1":"goldfish, Carassius auratus","2":"great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias","3":"tiger shark, Galeocerdo cuvieri","4":"hammerhead, hammerhead shark","5":"electric ray, crampfish, numbfish, torpedo","6":"stingray","7":"cock","8":"hen","9":"ostrich, Struthio camelus","10":"brambling, Fringilla montifringilla","11":"goldfinch, Carduelis carduelis","12":"house finch, linnet, Carpodacus mexicanus","13":"junco, snowbird","14":"indigo bunting, indigo finch, indigo bird, Passerina cyanea","15":"robin, American robin, Turdus migratorius","16":"bulbul","17":"jay","18":"magpie","19":"chickadee","20":"water ouzel, dipper","21":"kite","22":"bald eagle, American eagle, Haliaeetus leucocephalus","23":"vulture","24":"great grey owl, great gray owl, Strix nebulosa","25":"European fire salamander, Salamandra salamandra","26":"common newt, Triturus vulgaris","27":"eft","28":"spotted salamander, Ambystoma maculatum","29":"axolotl, mud puppy, Ambystoma mexicanum","30":"bullfrog, Rana catesbeiana","31":"tree frog, tree-frog","32":"tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui","33":"loggerhead, loggerhead turtle, Caretta caretta","34":"leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea","35":"mud turtle","36":"terrapin","37":"box turtle, box tortoise","38":"banded gecko","39":"common iguana, iguana, Iguana iguana","40":"American chameleon, anole, Anolis carolinensis","41":"whiptail, whiptail lizard","42":"agama","43":"frilled lizard, Chlamydosaurus kingi","44":"alligator lizard","45":"Gila monster, Heloderma suspectum","46":"green lizard, Lacerta viridis","47":"African chameleon, Chamaeleo chamaeleon","48":"Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis","49":"African crocodile, Nile crocodile, Crocodylus niloticus","50":"American alligator, Alligator mississipiensis","51":"triceratops","52":"thunder snake, worm snake, Carphophis amoenus","53":"ringneck snake, ring-necked snake, ring snake","54":"hognose snake, puff adder, sand viper","55":"green snake, grass snake","56":"king snake, kingsnake","57":"garter snake, grass snake","58":"water snake","59":"vine snake","60":"night snake, Hypsiglena torquata","61":"boa constrictor, Constrictor constrictor","62":"rock python, rock snake, Python sebae","63":"Indian cobra, Naja naja","64":"green mamba","65":"sea snake","66":"horned viper, cerastes, sand viper, horned asp, Cerastes cornutus","67":"diamondback, diamondback rattlesnake, Crotalus adamanteus","68":"sidewinder, horned rattlesnake, Crotalus cerastes","69":"trilobite","70":"harvestman, daddy longlegs, Phalangium opilio","71":"scorpion","72":"black and gold garden spider, Argiope aurantia","73":"barn spider, Araneus cavaticus","74":"garden spider, Aranea diademata","75":"black widow, Latrodectus mactans","76":"tarantula","77":"wolf spider, hunting spider","78":"tick","79":"centipede","80":"black grouse","81":"ptarmigan","82":"ruffed grouse, partridge, Bonasa umbellus","83":"prairie chicken, prairie grouse, prairie fowl","84":"peacock","85":"quail","86":"partridge","87":"African grey, African gray, Psittacus erithacus","88":"macaw","89":"sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita","90":"lorikeet","91":"coucal","92":"bee eater","93":"hornbill","94":"hummingbird","95":"jacamar","96":"toucan","97":"drake","98":"red-breasted merganser, Mergus serrator","99":"goose","100":"black swan, Cygnus atratus","101":"tusker","102":"echidna, spiny anteater, anteater","103":"platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus","104":"wallaby, brush kangaroo","105":"koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus","106":"wombat","107":"jelly fish","108":"sea anemone, anemone","109":"brain coral","110":"flatworm, platyhelminth","111":"nematode, nematode worm, roundworm","112":"conch","113":"snail","114":"slug","115":"sea slug, nudibranch","116":"chiton, coat-of-mail shell, sea cradle, polyplacophore","117":"chambered nautilus, pearly nautilus, nautilus","118":"Dungeness crab, Cancer magister","119":"rock crab, Cancer irroratus","120":"fiddler crab","121":"king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica","122":"American lobster, Northern lobster, Maine lobster, Homarus americanus","123":"spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish","124":"crayfish, crawfish, crawdad, crawdaddy","125":"hermit crab","126":"isopod","127":"white stork, Ciconia ciconia","128":"black stork, Ciconia nigra","129":"spoonbill","130":"flamingo","131":"little blue heron, Egretta caerulea","132":"American egret, great white heron, Egretta albus","133":"bittern","134":"crane","135":"limpkin, Aramus pictus","136":"European gallinule, Porphyrio porphyrio","137":"American coot, marsh hen, mud hen, water hen, Fulica americana","138":"bustard","139":"ruddy turnstone, Arenaria interpres","140":"red-backed sandpiper, dunlin, Erolia alpina","141":"redshank, Tringa totanus","142":"dowitcher","143":"oystercatcher, oyster catcher","144":"pelican","145":"king penguin, Aptenodytes patagonica","146":"albatross, mollymawk","147":"grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus","148":"killer whale, killer, orca, grampus, sea wolf, Orcinus orca","149":"dugong, Dugong dugon","150":"sea lion","151":"Chihuahua","152":"Japanese spaniel","153":"Maltese dog, Maltese terrier, Maltese","154":"Pekinese, Pekingese, Peke","155":"Shih-Tzu","156":"Blenheim spaniel","157":"papillon","158":"toy terrier","159":"Rhodesian ridgeback","160":"Afghan hound, Afghan","161":"basset, basset hound","162":"beagle","163":"bloodhound, sleuthhound","164":"bluetick","165":"black-and-tan coonhound","166":"Walker hound, Walker foxhound","167":"English foxhound","168":"redbone","169":"borzoi, Russian wolfhound","170":"Irish wolfhound","171":"Italian greyhound","172":"whippet","173":"Ibizan hound, Ibizan Podenco","174":"Norwegian elkhound, elkhound","175":"otterhound, otter hound","176":"Saluki, gazelle hound","177":"Scottish deerhound, deerhound","178":"Weimaraner","179":"Staffordshire bullterrier, Staffordshire bull terrier","180":"American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier","181":"Bedlington terrier","182":"Border terrier","183":"Kerry blue terrier","184":"Irish terrier","185":"Norfolk terrier","186":"Norwich terrier","187":"Yorkshire terrier","188":"wire-haired fox terrier","189":"Lakeland terrier","190":"Sealyham terrier, Sealyham","191":"Airedale, Airedale terrier","192":"cairn, cairn terrier","193":"Australian terrier","194":"Dandie Dinmont, Dandie Dinmont terrier","195":"Boston bull, Boston terrier","196":"miniature schnauzer","197":"giant schnauzer","198":"standard schnauzer","199":"Scotch terrier, Scottish terrier, Scottie","200":"Tibetan terrier, chrysanthemum dog","201":"silky terrier, Sydney silky","202":"soft-coated wheaten terrier","203":"West Highland white terrier","204":"Lhasa, Lhasa apso","205":"flat-coated retriever","206":"curly-coated retriever","207":"golden retriever","208":"Labrador retriever","209":"Chesapeake Bay retriever","210":"German short-haired pointer","211":"vizsla, Hungarian pointer","212":"English setter","213":"Irish setter, red setter","214":"Gordon setter","215":"Brittany spaniel","216":"clumber, clumber spaniel","217":"English springer, English springer spaniel","218":"Welsh springer spaniel","219":"cocker spaniel, English cocker spaniel, cocker","220":"Sussex spaniel","221":"Irish water spaniel","222":"kuvasz","223":"schipperke","224":"groenendael","225":"malinois","226":"briard","227":"kelpie","228":"komondor","229":"Old English sheepdog, bobtail","230":"Shetland sheepdog, Shetland sheep dog, Shetland","231":"collie","232":"Border collie","233":"Bouvier des Flandres, Bouviers des Flandres","234":"Rottweiler","235":"German shepherd, German shepherd dog, German police dog, alsatian","236":"Doberman, Doberman pinscher","237":"miniature pinscher","238":"Greater Swiss Mountain dog","239":"Bernese mountain dog","240":"Appenzeller","241":"EntleBucher","242":"boxer","243":"bull mastiff","244":"Tibetan mastiff","245":"French bulldog","246":"Great Dane","247":"Saint Bernard, St Bernard","248":"Eskimo dog, husky","249":"malamute, malemute, Alaskan malamute","250":"Siberian husky","251":"dalmatian, coach dog, carriage dog","252":"affenpinscher, monkey pinscher, monkey dog","253":"basenji","254":"pug, pug-dog","255":"Leonberg","256":"Newfoundland, Newfoundland dog","257":"Great Pyrenees","258":"Samoyed, Samoyede","259":"Pomeranian","260":"chow, chow chow","261":"keeshond","262":"Brabancon griffon","263":"Pembroke, Pembroke Welsh corgi","264":"Cardigan, Cardigan Welsh corgi","265":"toy poodle","266":"miniature poodle","267":"standard poodle","268":"Mexican hairless","269":"timber wolf, grey wolf, gray wolf, Canis lupus","270":"white wolf, Arctic wolf, Canis lupus tundrarum","271":"red wolf, maned wolf, Canis rufus, Canis niger","272":"coyote, prairie wolf, brush wolf, Canis latrans","273":"dingo, warrigal, warragal, Canis dingo","274":"dhole, Cuon alpinus","275":"African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus","276":"hyena, hyaena","277":"red fox, Vulpes vulpes","278":"kit fox, Vulpes macrotis","279":"Arctic fox, white fox, Alopex lagopus","280":"grey fox, gray fox, Urocyon cinereoargenteus","281":"tabby, tabby cat","282":"tiger cat","283":"Persian cat","284":"Siamese cat, Siamese","285":"Egyptian cat","286":"cougar, puma, catamount, mountain lion, painter, panther, Felis concolor","287":"lynx, catamount","288":"leopard, Panthera pardus","289":"snow leopard, ounce, Panthera uncia","290":"jaguar, panther, Panthera onca, Felis onca","291":"lion, king of beasts, Panthera leo","292":"tiger, Panthera tigris","293":"cheetah, chetah, Acinonyx jubatus","294":"brown bear, bruin, Ursus arctos","295":"American black bear, black bear, Ursus americanus, Euarctos americanus","296":"ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus","297":"sloth bear, Melursus ursinus, Ursus ursinus","298":"mongoose","299":"meerkat, mierkat","300":"tiger beetle","301":"ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle","302":"ground beetle, carabid beetle","303":"long-horned beetle, longicorn, longicorn beetle","304":"leaf beetle, chrysomelid","305":"dung beetle","306":"rhinoceros beetle","307":"weevil","308":"fly","309":"bee","310":"ant, emmet, pismire","311":"grasshopper, hopper","312":"cricket","313":"walking stick, walkingstick, stick insect","314":"cockroach, roach","315":"mantis, mantid","316":"cicada, cicala","317":"leafhopper","318":"lacewing, lacewing fly","319":"dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk","320":"damselfly","321":"admiral","322":"ringlet, ringlet butterfly","323":"monarch, monarch butterfly, milkweed butterfly, Danaus plexippus","324":"cabbage butterfly","325":"sulphur butterfly, sulfur butterfly","326":"lycaenid, lycaenid butterfly","327":"starfish, sea star","328":"sea urchin","329":"sea cucumber, holothurian","330":"wood rabbit, cottontail, cottontail rabbit","331":"hare","332":"Angora, Angora rabbit","333":"hamster","334":"porcupine, hedgehog","335":"fox squirrel, eastern fox squirrel, Sciurus niger","336":"marmot","337":"beaver","338":"guinea pig, Cavia cobaya","339":"sorrel","340":"zebra","341":"hog, pig, grunter, squealer, Sus scrofa","342":"wild boar, boar, Sus scrofa","343":"warthog","344":"hippopotamus, hippo, river horse, Hippopotamus amphibius","345":"ox","346":"water buffalo, water ox, Asiatic buffalo, Bubalus bubalis","347":"bison","348":"ram, tup","349":"bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis","350":"ibex, Capra ibex","351":"hartebeest","352":"impala, Aepyceros melampus","353":"gazelle","354":"Arabian camel, dromedary, Camelus dromedarius","355":"llama","356":"weasel","357":"mink","358":"polecat, fitch, foulmart, foumart, Mustela putorius","359":"black-footed ferret, ferret, Mustela nigripes","360":"otter","361":"skunk, polecat, wood pussy","362":"badger","363":"armadillo","364":"three-toed sloth, ai, Bradypus tridactylus","365":"orangutan, orang, orangutang, Pongo pygmaeus","366":"gorilla, Gorilla gorilla","367":"chimpanzee, chimp, Pan troglodytes","368":"gibbon, Hylobates lar","369":"siamang, Hylobates syndactylus, Symphalangus syndactylus","370":"guenon, guenon monkey","371":"patas, hussar monkey, Erythrocebus patas","372":"baboon","373":"macaque","374":"langur","375":"colobus, colobus monkey","376":"proboscis monkey, Nasalis larvatus","377":"marmoset","378":"capuchin, ringtail, Cebus capucinus","379":"howler monkey, howler","380":"titi, titi monkey","381":"spider monkey, Ateles geoffroyi","382":"squirrel monkey, Saimiri sciureus","383":"Madagascar cat, ring-tailed lemur, Lemur catta","384":"indri, indris, Indri indri, Indri brevicaudatus","385":"Indian elephant, Elephas maximus","386":"African elephant, Loxodonta africana","387":"lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens","388":"giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca","389":"barracouta, snoek","390":"eel","391":"coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch","392":"rock beauty, Holocanthus tricolor","393":"anemone fish","394":"sturgeon","395":"gar, garfish, garpike, billfish, Lepisosteus osseus","396":"lionfish","397":"puffer, pufferfish, blowfish, globefish","398":"abacus","399":"abaya","400":"academic gown, academic robe, judge's robe","401":"accordion, piano accordion, squeeze box","402":"acoustic guitar","403":"aircraft carrier, carrier, flattop, attack aircraft carrier","404":"airliner","405":"airship, dirigible","406":"altar","407":"ambulance","408":"amphibian, amphibious vehicle","409":"analog clock","410":"apiary, bee house","411":"apron","412":"ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin","413":"assault rifle, assault gun","414":"backpack, back pack, knapsack, packsack, rucksack, haversack","415":"bakery, bakeshop, bakehouse","416":"balance beam, beam","417":"balloon","418":"ballpoint, ballpoint pen, ballpen, Biro","419":"Band Aid","420":"banjo","421":"bannister, banister, balustrade, balusters, handrail","422":"barbell","423":"barber chair","424":"barbershop","425":"barn","426":"barometer","427":"barrel, cask","428":"barrow, garden cart, lawn cart, wheelbarrow","429":"baseball","430":"basketball","431":"bassinet","432":"bassoon","433":"bathing cap, swimming cap","434":"bath towel","435":"bathtub, bathing tub, bath, tub","436":"beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon","437":"beacon, lighthouse, beacon light, pharos","438":"beaker","439":"bearskin, busby, shako","440":"beer bottle","441":"beer glass","442":"bell cote, bell cot","443":"bib","444":"bicycle-built-for-two, tandem bicycle, tandem","445":"bikini, two-piece","446":"binder, ring-binder","447":"binoculars, field glasses, opera glasses","448":"birdhouse","449":"boathouse","450":"bobsled, bobsleigh, bob","451":"bolo tie, bolo, bola tie, bola","452":"bonnet, poke bonnet","453":"bookcase","454":"bookshop, bookstore, bookstall","455":"bottlecap","456":"bow","457":"bow tie, bow-tie, bowtie","458":"brass, memorial tablet, plaque","459":"brassiere, bra, bandeau","460":"breakwater, groin, groyne, mole, bulwark, seawall, jetty","461":"breastplate, aegis, egis","462":"broom","463":"bucket, pail","464":"buckle","465":"bulletproof vest","466":"bullet train, bullet","467":"butcher shop, meat market","468":"cab, hack, taxi, taxicab","469":"caldron, cauldron","470":"candle, taper, wax light","471":"cannon","472":"canoe","473":"can opener, tin opener","474":"cardigan","475":"car mirror","476":"carousel, carrousel, merry-go-round, roundabout, whirligig","477":"carpenter's kit, tool kit","478":"carton","479":"car wheel","480":"cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM","481":"cassette","482":"cassette player","483":"castle","484":"catamaran","485":"CD player","486":"cello, violoncello","487":"cellular telephone, cellular phone, cellphone, cell, mobile phone","488":"chain","489":"chainlink fence","490":"chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour","491":"chain saw, chainsaw","492":"chest","493":"chiffonier, commode","494":"chime, bell, gong","495":"china cabinet, china closet","496":"Christmas stocking","497":"church, church building","498":"cinema, movie theater, movie theatre, movie house, picture palace","499":"cleaver, meat cleaver, chopper","500":"cliff dwelling","501":"cloak","502":"clog, geta, patten, sabot","503":"cocktail shaker","504":"coffee mug","505":"coffeepot","506":"coil, spiral, volute, whorl, helix","507":"combination lock","508":"computer keyboard, keypad","509":"confectionery, confectionary, candy store","510":"container ship, containership, container vessel","511":"convertible","512":"corkscrew, bottle screw","513":"cornet, horn, trumpet, trump","514":"cowboy boot","515":"cowboy hat, ten-gallon hat","516":"cradle","517":"crane","518":"crash helmet","519":"crate","520":"crib, cot","521":"Crock Pot","522":"croquet ball","523":"crutch","524":"cuirass","525":"dam, dike, dyke","526":"desk","527":"desktop computer","528":"dial telephone, dial phone","529":"diaper, nappy, napkin","530":"digital clock","531":"digital watch","532":"dining table, board","533":"dishrag, dishcloth","534":"dishwasher, dish washer, dishwashing machine","535":"disk brake, disc brake","536":"dock, dockage, docking facility","537":"dogsled, dog sled, dog sleigh","538":"dome","539":"doormat, welcome mat","540":"drilling platform, offshore rig","541":"drum, membranophone, tympan","542":"drumstick","543":"dumbbell","544":"Dutch oven","545":"electric fan, blower","546":"electric guitar","547":"electric locomotive","548":"entertainment center","549":"envelope","550":"espresso maker","551":"face powder","552":"feather boa, boa","553":"file, file cabinet, filing cabinet","554":"fireboat","555":"fire engine, fire truck","556":"fire screen, fireguard","557":"flagpole, flagstaff","558":"flute, transverse flute","559":"folding chair","560":"football helmet","561":"forklift","562":"fountain","563":"fountain pen","564":"four-poster","565":"freight car","566":"French horn, horn","567":"frying pan, frypan, skillet","568":"fur coat","569":"garbage truck, dustcart","570":"gasmask, respirator, gas helmet","571":"gas pump, gasoline pump, petrol pump, island dispenser","572":"goblet","573":"go-kart","574":"golf ball","575":"golfcart, golf cart","576":"gondola","577":"gong, tam-tam","578":"gown","579":"grand piano, grand","580":"greenhouse, nursery, glasshouse","581":"grille, radiator grille","582":"grocery store, grocery, food market, market","583":"guillotine","584":"hair slide","585":"hair spray","586":"half track","587":"hammer","588":"hamper","589":"hand blower, blow dryer, blow drier, hair dryer, hair drier","590":"hand-held computer, hand-held microcomputer","591":"handkerchief, hankie, hanky, hankey","592":"hard disc, hard disk, fixed disk","593":"harmonica, mouth organ, harp, mouth harp","594":"harp","595":"harvester, reaper","596":"hatchet","597":"holster","598":"home theater, home theatre","599":"honeycomb","600":"hook, claw","601":"hoopskirt, crinoline","602":"horizontal bar, high bar","603":"horse cart, horse-cart","604":"hourglass","605":"iPod","606":"iron, smoothing iron","607":"jack-o'-lantern","608":"jean, blue jean, denim","609":"jeep, landrover","610":"jersey, T-shirt, tee shirt","611":"jigsaw puzzle","612":"jinrikisha, ricksha, rickshaw","613":"joystick","614":"kimono","615":"knee pad","616":"knot","617":"lab coat, laboratory coat","618":"ladle","619":"lampshade, lamp shade","620":"laptop, laptop computer","621":"lawn mower, mower","622":"lens cap, lens cover","623":"letter opener, paper knife, paperknife","624":"library","625":"lifeboat","626":"lighter, light, igniter, ignitor","627":"limousine, limo","628":"liner, ocean liner","629":"lipstick, lip rouge","630":"Loafer","631":"lotion","632":"loudspeaker, speaker, speaker unit, loudspeaker system, speaker system","633":"loupe, jeweler's loupe","634":"lumbermill, sawmill","635":"magnetic compass","636":"mailbag, postbag","637":"mailbox, letter box","638":"maillot","639":"maillot, tank suit","640":"manhole cover","641":"maraca","642":"marimba, xylophone","643":"mask","644":"matchstick","645":"maypole","646":"maze, labyrinth","647":"measuring cup","648":"medicine chest, medicine cabinet","649":"megalith, megalithic structure","650":"microphone, mike","651":"microwave, microwave oven","652":"military uniform","653":"milk can","654":"minibus","655":"miniskirt, mini","656":"minivan","657":"missile","658":"mitten","659":"mixing bowl","660":"mobile home, manufactured home","661":"Model T","662":"modem","663":"monastery","664":"monitor","665":"moped","666":"mortar","667":"mortarboard","668":"mosque","669":"mosquito net","670":"motor scooter, scooter","671":"mountain bike, all-terrain bike, off-roader","672":"mountain tent","673":"mouse, computer mouse","674":"mousetrap","675":"moving van","676":"muzzle","677":"nail","678":"neck brace","679":"necklace","680":"nipple","681":"notebook, notebook computer","682":"obelisk","683":"oboe, hautboy, hautbois","684":"ocarina, sweet potato","685":"odometer, hodometer, mileometer, milometer","686":"oil filter","687":"organ, pipe organ","688":"oscilloscope, scope, cathode-ray oscilloscope, CRO","689":"overskirt","690":"oxcart","691":"oxygen mask","692":"packet","693":"paddle, boat paddle","694":"paddlewheel, paddle wheel","695":"padlock","696":"paintbrush","697":"pajama, pyjama, pj's, jammies","698":"palace","699":"panpipe, pandean pipe, syrinx","700":"paper towel","701":"parachute, chute","702":"parallel bars, bars","703":"park bench","704":"parking meter","705":"passenger car, coach, carriage","706":"patio, terrace","707":"pay-phone, pay-station","708":"pedestal, plinth, footstall","709":"pencil box, pencil case","710":"pencil sharpener","711":"perfume, essence","712":"Petri dish","713":"photocopier","714":"pick, plectrum, plectron","715":"pickelhaube","716":"picket fence, paling","717":"pickup, pickup truck","718":"pier","719":"piggy bank, penny bank","720":"pill bottle","721":"pillow","722":"ping-pong ball","723":"pinwheel","724":"pirate, pirate ship","725":"pitcher, ewer","726":"plane, carpenter's plane, woodworking plane","727":"planetarium","728":"plastic bag","729":"plate rack","730":"plow, plough","731":"plunger, plumber's helper","732":"Polaroid camera, Polaroid Land camera","733":"pole","734":"police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria","735":"poncho","736":"pool table, billiard table, snooker table","737":"pop bottle, soda bottle","738":"pot, flowerpot","739":"potter's wheel","740":"power drill","741":"prayer rug, prayer mat","742":"printer","743":"prison, prison house","744":"projectile, missile","745":"projector","746":"puck, hockey puck","747":"punching bag, punch bag, punching ball, punchball","748":"purse","749":"quill, quill pen","750":"quilt, comforter, comfort, puff","751":"racer, race car, racing car","752":"racket, racquet","753":"radiator","754":"radio, wireless","755":"radio telescope, radio reflector","756":"rain barrel","757":"recreational vehicle, RV, R.V.","758":"reel","759":"reflex camera","760":"refrigerator, icebox","761":"remote control, remote","762":"restaurant, eating house, eating place, eatery","763":"revolver, six-gun, six-shooter","764":"rifle","765":"rocking chair, rocker","766":"rotisserie","767":"rubber eraser, rubber, pencil eraser","768":"rugby ball","769":"rule, ruler","770":"running shoe","771":"safe","772":"safety pin","773":"saltshaker, salt shaker","774":"sandal","775":"sarong","776":"sax, saxophone","777":"scabbard","778":"scale, weighing machine","779":"school bus","780":"schooner","781":"scoreboard","782":"screen, CRT screen","783":"screw","784":"screwdriver","785":"seat belt, seatbelt","786":"sewing machine","787":"shield, buckler","788":"shoe shop, shoe-shop, shoe store","789":"shoji","790":"shopping basket","791":"shopping cart","792":"shovel","793":"shower cap","794":"shower curtain","795":"ski","796":"ski mask","797":"sleeping bag","798":"slide rule, slipstick","799":"sliding door","800":"slot, one-armed bandit","801":"snorkel","802":"snowmobile","803":"snowplow, snowplough","804":"soap dispenser","805":"soccer ball","806":"sock","807":"solar dish, solar collector, solar furnace","808":"sombrero","809":"soup bowl","810":"space bar","811":"space heater","812":"space shuttle","813":"spatula","814":"speedboat","815":"spider web, spider's web","816":"spindle","817":"sports car, sport car","818":"spotlight, spot","819":"stage","820":"steam locomotive","821":"steel arch bridge","822":"steel drum","823":"stethoscope","824":"stole","825":"stone wall","826":"stopwatch, stop watch","827":"stove","828":"strainer","829":"streetcar, tram, tramcar, trolley, trolley car","830":"stretcher","831":"studio couch, day bed","832":"stupa, tope","833":"submarine, pigboat, sub, U-boat","834":"suit, suit of clothes","835":"sundial","836":"sunglass","837":"sunglasses, dark glasses, shades","838":"sunscreen, sunblock, sun blocker","839":"suspension bridge","840":"swab, swob, mop","841":"sweatshirt","842":"swimming trunks, bathing trunks","843":"swing","844":"switch, electric switch, electrical switch","845":"syringe","846":"table lamp","847":"tank, army tank, armored combat vehicle, armoured combat vehicle","848":"tape player","849":"teapot","850":"teddy, teddy bear","851":"television, television system","852":"tennis ball","853":"thatch, thatched roof","854":"theater curtain, theatre curtain","855":"thimble","856":"thresher, thrasher, threshing machine","857":"throne","858":"tile roof","859":"toaster","860":"tobacco shop, tobacconist shop, tobacconist","861":"toilet seat","862":"torch","863":"totem pole","864":"tow truck, tow car, wrecker","865":"toyshop","866":"tractor","867":"trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi","868":"tray","869":"trench coat","870":"tricycle, trike, velocipede","871":"trimaran","872":"tripod","873":"triumphal arch","874":"trolleybus, trolley coach, trackless trolley","875":"trombone","876":"tub, vat","877":"turnstile","878":"typewriter keyboard","879":"umbrella","880":"unicycle, monocycle","881":"upright, upright piano","882":"vacuum, vacuum cleaner","883":"vase","884":"vault","885":"velvet","886":"vending machine","887":"vestment","888":"viaduct","889":"violin, fiddle","890":"volleyball","891":"waffle iron","892":"wall clock","893":"wallet, billfold, notecase, pocketbook","894":"wardrobe, closet, press","895":"warplane, military plane","896":"washbasin, handbasin, washbowl, lavabo, wash-hand basin","897":"washer, automatic washer, washing machine","898":"water bottle","899":"water jug","900":"water tower","901":"whiskey jug","902":"whistle","903":"wig","904":"window screen","905":"window shade","906":"Windsor tie","907":"wine bottle","908":"wing","909":"wok","910":"wooden spoon","911":"wool, woolen, woollen","912":"worm fence, snake fence, snake-rail fence, Virginia fence","913":"wreck","914":"yawl","915":"yurt","916":"web site, website, internet site, site","917":"comic book","918":"crossword puzzle, crossword","919":"street sign","920":"traffic light, traffic signal, stoplight","921":"book jacket, dust cover, dust jacket, dust wrapper","922":"menu","923":"plate","924":"guacamole","925":"consomme","926":"hot pot, hotpot","927":"trifle","928":"ice cream, icecream","929":"ice lolly, lolly, lollipop, popsicle","930":"French loaf","931":"bagel, beigel","932":"pretzel","933":"cheeseburger","934":"hotdog, hot dog, red hot","935":"mashed potato","936":"head cabbage","937":"broccoli","938":"cauliflower","939":"zucchini, courgette","940":"spaghetti squash","941":"acorn squash","942":"butternut squash","943":"cucumber, cuke","944":"artichoke, globe artichoke","945":"bell pepper","946":"cardoon","947":"mushroom","948":"Granny Smith","949":"strawberry","950":"orange","951":"lemon","952":"fig","953":"pineapple, ananas","954":"banana","955":"jackfruit, jak, jack","956":"custard apple","957":"pomegranate","958":"hay","959":"carbonara","960":"chocolate sauce, chocolate syrup","961":"dough","962":"meat loaf, meatloaf","963":"pizza, pizza pie","964":"potpie","965":"burrito","966":"red wine","967":"espresso","968":"cup","969":"eggnog","970":"alp","971":"bubble","972":"cliff, drop, drop-off","973":"coral reef","974":"geyser","975":"lakeside, lakeshore","976":"promontory, headland, head, foreland","977":"sandbar, sand bar","978":"seashore, coast, seacoast, sea-coast","979":"valley, vale","980":"volcano","981":"ballplayer, baseball player","982":"groom, bridegroom","983":"scuba diver","984":"rapeseed","985":"daisy","986":"yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum","987":"corn","988":"acorn","989":"hip, rose hip, rosehip","990":"buckeye, horse chestnut, conker","991":"coral fungus","992":"agaric","993":"gyromitra","994":"stinkhorn, carrion fungus","995":"earthstar","996":"hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa","997":"bolete","998":"ear, spike, capitulum","999":"toilet tissue, toilet paper, bathroom tissue"} diff --git a/model/mobilenet.json b/model/mobilenet.json new file mode 100644 index 0000000..ef109ee --- /dev/null +++ b/model/mobilenet.json @@ -0,0 +1 @@ +{"modelTopology": {"keras_version": "2.1.4", "model_config": {"class_name": "Model", "config": {"layers": [{"class_name": "InputLayer", "inbound_nodes": [], "config": {"dtype": "float32", "batch_input_shape": [null, 224, 224, 3], "name": "input_1", "sparse": false}, "name": "input_1"}, {"class_name": "Conv2D", "inbound_nodes": [[["input_1", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv1", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [2, 2], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 8, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv1"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv1", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv1_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv1_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv1_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv1_relu"}, "name": "conv1_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv1_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_1", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_1"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_1", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_1_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_1_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_1_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_1_relu"}, "name": "conv_dw_1_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_1_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_1", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 16, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_1"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_1", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_1_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_1_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_1_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_1_relu"}, "name": "conv_pw_1_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_1_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_2", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [2, 2], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_2"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_2", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_2_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_2_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_2_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_2_relu"}, "name": "conv_dw_2_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_2_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_2", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 32, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_2"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_2", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_2_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_2_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_2_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_2_relu"}, "name": "conv_pw_2_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_2_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_3", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_3"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_3", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_3_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_3_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_3_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_3_relu"}, "name": "conv_dw_3_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_3_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_3", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 32, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_3"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_3", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_3_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_3_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_3_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_3_relu"}, "name": "conv_pw_3_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_3_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_4", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [2, 2], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_4"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_4", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_4_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_4_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_4_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_4_relu"}, "name": "conv_dw_4_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_4_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_4", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 64, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_4"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_4", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_4_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_4_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_4_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_4_relu"}, "name": "conv_pw_4_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_4_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_5", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_5"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_5", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_5_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_5_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_5_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_5_relu"}, "name": "conv_dw_5_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_5_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_5", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 64, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_5"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_5", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_5_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_5_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_5_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_5_relu"}, "name": "conv_pw_5_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_5_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_6", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [2, 2], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_6"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_6", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_6_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_6_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_6_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_6_relu"}, "name": "conv_dw_6_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_6_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_6", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_6"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_6", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_6_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_6_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_6_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_6_relu"}, "name": "conv_pw_6_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_6_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_7", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_7"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_7", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_7_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_7_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_7_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_7_relu"}, "name": "conv_dw_7_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_7_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_7", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_7"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_7", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_7_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_7_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_7_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_7_relu"}, "name": "conv_pw_7_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_7_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_8", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_8"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_8", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_8_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_8_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_8_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_8_relu"}, "name": "conv_dw_8_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_8_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_8", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_8"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_8", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_8_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_8_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_8_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_8_relu"}, "name": "conv_pw_8_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_8_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_9", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_9"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_9", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_9_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_9_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_9_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_9_relu"}, "name": "conv_dw_9_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_9_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_9", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_9"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_9", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_9_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_9_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_9_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_9_relu"}, "name": "conv_pw_9_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_9_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_10", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_10"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_10", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_10_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_10_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_10_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_10_relu"}, "name": "conv_dw_10_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_10_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_10", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_10"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_10", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_10_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_10_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_10_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_10_relu"}, "name": "conv_pw_10_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_10_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_11", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_11"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_11", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_11_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_11_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_11_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_11_relu"}, "name": "conv_dw_11_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_11_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_11", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 128, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_11"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_11", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_11_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_11_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_11_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_11_relu"}, "name": "conv_pw_11_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_11_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_12", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [2, 2], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_12"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_12", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_12_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_12_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_12_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_12_relu"}, "name": "conv_dw_12_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_12_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_12", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 256, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_12"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_12", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_12_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_12_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_12_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_12_relu"}, "name": "conv_pw_12_relu"}, {"class_name": "DepthwiseConv2D", "inbound_nodes": [[["conv_pw_12_relu", 0, 0, {}]]], "config": {"padding": "same", "depth_multiplier": 1, "name": "conv_dw_13", "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "depthwise_constraint": null, "strides": [1, 1], "dilation_rate": [1, 1], "depthwise_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "depthwise_regularizer": null, "use_bias": false, "activity_regularizer": null, "kernel_size": [3, 3]}, "name": "conv_dw_13"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_dw_13", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_dw_13_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_dw_13_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_dw_13_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_dw_13_relu"}, "name": "conv_dw_13_relu"}, {"class_name": "Conv2D", "inbound_nodes": [[["conv_dw_13_relu", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_pw_13", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 256, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": false, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_pw_13"}, {"class_name": "BatchNormalization", "inbound_nodes": [[["conv_pw_13", 0, 0, {}]]], "config": {"gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "name": "conv_pw_13_bn", "epsilon": 0.001, "trainable": true, "center": true, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_initializer": {"class_name": "Zeros", "config": {}}, "scale": true, "gamma_regularizer": null, "gamma_constraint": null, "beta_constraint": null, "beta_regularizer": null, "momentum": 0.99, "axis": -1}, "name": "conv_pw_13_bn"}, {"class_name": "Activation", "inbound_nodes": [[["conv_pw_13_bn", 0, 0, {}]]], "config": {"activation": "relu6", "trainable": true, "name": "conv_pw_13_relu"}, "name": "conv_pw_13_relu"}, {"class_name": "GlobalAveragePooling2D", "inbound_nodes": [[["conv_pw_13_relu", 0, 0, {}]]], "config": {"trainable": true, "name": "global_average_pooling2d_1", "data_format": "channels_last"}, "name": "global_average_pooling2d_1"}, {"class_name": "Reshape", "inbound_nodes": [[["global_average_pooling2d_1", 0, 0, {}]]], "config": {"target_shape": [1, 1, 256], "trainable": true, "name": "reshape_1"}, "name": "reshape_1"}, {"class_name": "Dropout", "inbound_nodes": [[["reshape_1", 0, 0, {}]]], "config": {"rate": 0.001, "noise_shape": null, "trainable": true, "seed": null, "name": "dropout"}, "name": "dropout"}, {"class_name": "Conv2D", "inbound_nodes": [[["dropout", 0, 0, {}]]], "config": {"kernel_initializer": {"class_name": "VarianceScaling", "config": {"distribution": "uniform", "scale": 1.0, "seed": null, "mode": "fan_avg"}}, "name": "conv_preds", "kernel_constraint": null, "bias_regularizer": null, "bias_constraint": null, "activation": "linear", "trainable": true, "data_format": "channels_last", "padding": "same", "strides": [1, 1], "dilation_rate": [1, 1], "kernel_regularizer": null, "filters": 1000, "bias_initializer": {"class_name": "Zeros", "config": {}}, "use_bias": true, "activity_regularizer": null, "kernel_size": [1, 1]}, "name": "conv_preds"}, {"class_name": "Activation", "inbound_nodes": [[["conv_preds", 0, 0, {}]]], "config": {"activation": "softmax", "trainable": true, "name": "act_softmax"}, "name": "act_softmax"}, {"class_name": "Reshape", "inbound_nodes": [[["act_softmax", 0, 0, {}]]], "config": {"target_shape": [1000], "trainable": true, "name": "reshape_2"}, "name": "reshape_2"}], "input_layers": [["input_1", 0, 0]], "name": "mobilenet_0.25_224", "output_layers": [["reshape_2", 0, 0]]}}, "backend": "tensorflow"}, "weightsManifest": [{"paths": ["group1-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 3, 8], "name": "conv1/kernel"}]}, {"paths": ["group2-shard1of1"], "weights": [{"dtype": "float32", "shape": [8], "name": "conv1_bn/gamma"}, {"dtype": "float32", "shape": [8], "name": "conv1_bn/beta"}, {"dtype": "float32", "shape": [8], "name": "conv1_bn/moving_mean"}, {"dtype": "float32", "shape": [8], "name": "conv1_bn/moving_variance"}]}, {"paths": ["group3-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 8, 1], "name": "conv_dw_1/depthwise_kernel"}]}, {"paths": ["group4-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_10/depthwise_kernel"}]}, {"paths": ["group5-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_10_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_10_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_10_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_10_bn/moving_variance"}]}, {"paths": ["group6-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_11/depthwise_kernel"}]}, {"paths": ["group7-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_11_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_11_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_11_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_11_bn/moving_variance"}]}, {"paths": ["group8-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_12/depthwise_kernel"}]}, {"paths": ["group9-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_12_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_12_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_12_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_12_bn/moving_variance"}]}, {"paths": ["group10-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 256, 1], "name": "conv_dw_13/depthwise_kernel"}]}, {"paths": ["group11-shard1of1"], "weights": [{"dtype": "float32", "shape": [256], "name": "conv_dw_13_bn/gamma"}, {"dtype": "float32", "shape": [256], "name": "conv_dw_13_bn/beta"}, {"dtype": "float32", "shape": [256], "name": "conv_dw_13_bn/moving_mean"}, {"dtype": "float32", "shape": [256], "name": "conv_dw_13_bn/moving_variance"}]}, {"paths": ["group12-shard1of1"], "weights": [{"dtype": "float32", "shape": [8], "name": "conv_dw_1_bn/gamma"}, {"dtype": "float32", "shape": [8], "name": "conv_dw_1_bn/beta"}, {"dtype": "float32", "shape": [8], "name": "conv_dw_1_bn/moving_mean"}, {"dtype": "float32", "shape": [8], "name": "conv_dw_1_bn/moving_variance"}]}, {"paths": ["group13-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 16, 1], "name": "conv_dw_2/depthwise_kernel"}]}, {"paths": ["group14-shard1of1"], "weights": [{"dtype": "float32", "shape": [16], "name": "conv_dw_2_bn/gamma"}, {"dtype": "float32", "shape": [16], "name": "conv_dw_2_bn/beta"}, {"dtype": "float32", "shape": [16], "name": "conv_dw_2_bn/moving_mean"}, {"dtype": "float32", "shape": [16], "name": "conv_dw_2_bn/moving_variance"}]}, {"paths": ["group15-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 32, 1], "name": "conv_dw_3/depthwise_kernel"}]}, {"paths": ["group16-shard1of1"], "weights": [{"dtype": "float32", "shape": [32], "name": "conv_dw_3_bn/gamma"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_3_bn/beta"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_3_bn/moving_mean"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_3_bn/moving_variance"}]}, {"paths": ["group17-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 32, 1], "name": "conv_dw_4/depthwise_kernel"}]}, {"paths": ["group18-shard1of1"], "weights": [{"dtype": "float32", "shape": [32], "name": "conv_dw_4_bn/gamma"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_4_bn/beta"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_4_bn/moving_mean"}, {"dtype": "float32", "shape": [32], "name": "conv_dw_4_bn/moving_variance"}]}, {"paths": ["group19-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 64, 1], "name": "conv_dw_5/depthwise_kernel"}]}, {"paths": ["group20-shard1of1"], "weights": [{"dtype": "float32", "shape": [64], "name": "conv_dw_5_bn/gamma"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_5_bn/beta"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_5_bn/moving_mean"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_5_bn/moving_variance"}]}, {"paths": ["group21-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 64, 1], "name": "conv_dw_6/depthwise_kernel"}]}, {"paths": ["group22-shard1of1"], "weights": [{"dtype": "float32", "shape": [64], "name": "conv_dw_6_bn/gamma"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_6_bn/beta"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_6_bn/moving_mean"}, {"dtype": "float32", "shape": [64], "name": "conv_dw_6_bn/moving_variance"}]}, {"paths": ["group23-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_7/depthwise_kernel"}]}, {"paths": ["group24-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_7_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_7_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_7_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_7_bn/moving_variance"}]}, {"paths": ["group25-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_8/depthwise_kernel"}]}, {"paths": ["group26-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_8_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_8_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_8_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_8_bn/moving_variance"}]}, {"paths": ["group27-shard1of1"], "weights": [{"dtype": "float32", "shape": [3, 3, 128, 1], "name": "conv_dw_9/depthwise_kernel"}]}, {"paths": ["group28-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_dw_9_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_9_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_9_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_dw_9_bn/moving_variance"}]}, {"paths": ["group29-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 256, 1000], "name": "conv_preds/kernel"}, {"dtype": "float32", "shape": [1000], "name": "conv_preds/bias"}]}, {"paths": ["group30-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 8, 16], "name": "conv_pw_1/kernel"}]}, {"paths": ["group31-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 128], "name": "conv_pw_10/kernel"}]}, {"paths": ["group32-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_10_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_10_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_10_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_10_bn/moving_variance"}]}, {"paths": ["group33-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 128], "name": "conv_pw_11/kernel"}]}, {"paths": ["group34-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_11_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_11_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_11_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_11_bn/moving_variance"}]}, {"paths": ["group35-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 256], "name": "conv_pw_12/kernel"}]}, {"paths": ["group36-shard1of1"], "weights": [{"dtype": "float32", "shape": [256], "name": "conv_pw_12_bn/gamma"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_12_bn/beta"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_12_bn/moving_mean"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_12_bn/moving_variance"}]}, {"paths": ["group37-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 256, 256], "name": "conv_pw_13/kernel"}]}, {"paths": ["group38-shard1of1"], "weights": [{"dtype": "float32", "shape": [256], "name": "conv_pw_13_bn/gamma"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_13_bn/beta"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_13_bn/moving_mean"}, {"dtype": "float32", "shape": [256], "name": "conv_pw_13_bn/moving_variance"}]}, {"paths": ["group39-shard1of1"], "weights": [{"dtype": "float32", "shape": [16], "name": "conv_pw_1_bn/gamma"}, {"dtype": "float32", "shape": [16], "name": "conv_pw_1_bn/beta"}, {"dtype": "float32", "shape": [16], "name": "conv_pw_1_bn/moving_mean"}, {"dtype": "float32", "shape": [16], "name": "conv_pw_1_bn/moving_variance"}]}, {"paths": ["group40-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 16, 32], "name": "conv_pw_2/kernel"}]}, {"paths": ["group41-shard1of1"], "weights": [{"dtype": "float32", "shape": [32], "name": "conv_pw_2_bn/gamma"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_2_bn/beta"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_2_bn/moving_mean"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_2_bn/moving_variance"}]}, {"paths": ["group42-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 32, 32], "name": "conv_pw_3/kernel"}]}, {"paths": ["group43-shard1of1"], "weights": [{"dtype": "float32", "shape": [32], "name": "conv_pw_3_bn/gamma"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_3_bn/beta"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_3_bn/moving_mean"}, {"dtype": "float32", "shape": [32], "name": "conv_pw_3_bn/moving_variance"}]}, {"paths": ["group44-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 32, 64], "name": "conv_pw_4/kernel"}]}, {"paths": ["group45-shard1of1"], "weights": [{"dtype": "float32", "shape": [64], "name": "conv_pw_4_bn/gamma"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_4_bn/beta"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_4_bn/moving_mean"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_4_bn/moving_variance"}]}, {"paths": ["group46-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 64, 64], "name": "conv_pw_5/kernel"}]}, {"paths": ["group47-shard1of1"], "weights": [{"dtype": "float32", "shape": [64], "name": "conv_pw_5_bn/gamma"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_5_bn/beta"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_5_bn/moving_mean"}, {"dtype": "float32", "shape": [64], "name": "conv_pw_5_bn/moving_variance"}]}, {"paths": ["group48-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 64, 128], "name": "conv_pw_6/kernel"}]}, {"paths": ["group49-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_6_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_6_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_6_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_6_bn/moving_variance"}]}, {"paths": ["group50-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 128], "name": "conv_pw_7/kernel"}]}, {"paths": ["group51-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_7_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_7_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_7_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_7_bn/moving_variance"}]}, {"paths": ["group52-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 128], "name": "conv_pw_8/kernel"}]}, {"paths": ["group53-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_8_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_8_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_8_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_8_bn/moving_variance"}]}, {"paths": ["group54-shard1of1"], "weights": [{"dtype": "float32", "shape": [1, 1, 128, 128], "name": "conv_pw_9/kernel"}]}, {"paths": ["group55-shard1of1"], "weights": [{"dtype": "float32", "shape": [128], "name": "conv_pw_9_bn/gamma"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_9_bn/beta"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_9_bn/moving_mean"}, {"dtype": "float32", "shape": [128], "name": "conv_pw_9_bn/moving_variance"}]}]} \ No newline at end of file diff --git a/notification.ogg b/notification.ogg new file mode 100644 index 0000000..2f513ef Binary files /dev/null and b/notification.ogg differ diff --git a/roboto-black.ttf b/roboto-black.ttf new file mode 100644 index 0000000..689fe5c Binary files /dev/null and b/roboto-black.ttf differ diff --git a/tensorflow.js b/tensorflow.js new file mode 100644 index 0000000..a2a4c67 --- /dev/null +++ b/tensorflow.js @@ -0,0 +1 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tf=e()}}(function(){return function(){function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("./doc"),a=function(){function e(){}return e.nextFrame=function(){return new Promise(function(e){return requestAnimationFrame(function(){return e()})})},r([i.doc({heading:"Performance",subheading:"Timing"})],e,"nextFrame",null),e}();n.BrowserUtil=a},{"./doc":3}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.isMobile=function(){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}},{}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.doc=function(e){return function(){for(var e=[],t=0;t0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1] {...}) to avoid memory leaks.");return this.activeScope.keep.push(e),e},e.prototype.startScope=function(e,t){void 0===t&&(t=!1),t&&0===this.gradientScopeCount&&(this.activeTape=[]),t&&this.gradientScopeCount++;var n={keep:[],track:[]};e&&(n.name=e),this.scopeStack.push(n),this.activeScope=n},e.prototype.endScope=function(e,t){var n=this;void 0===t&&(t=!1),t&&0===--this.gradientScopeCount&&(this.activeTape=null);var r=this.activeScope.keep,i=p.extractTensorsFromContainer(e);r=r.concat(i);for(var a=0;a0,"gradients() received an empty list of xs."),o.tidy("gradients",function(){var a=e();p.assert(a instanceof c.Tensor,"The result y returned by f() must be a tensor.");var o=l.getFilteredNodesXToY(i.activeTape,t,a);if(!r&&0===o.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");var u={};return u[a.id]=null==n?s.ones(a.shape):n,l.backpropagateGradients(u,o),{value:a,grads:t.map(function(e){return u[e.id]})}},!0)},e.prototype.customGrad=function(e){var t=this;return p.assert(p.isFunction(e),"The f passed in customGrad(f) must be a function."),function(){for(var n=[],r=0;r {op();...}); to avoid memory leaks.");return this.activeScope.track.push(e),e},e}();n.Engine=h},{"./environment":5,"./globals":6,"./ops/ops":66,"./profiler":87,"./tape":88,"./tensor":89,"./util":95}],5:[function(e,t,n){(function(t){"use strict";function r(e,t){return null!=e.getExtension(t)}function i(e){if(0===e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var t=document.createElement("canvas");return 1===e?t.getContext("webgl")||t.getContext("experimental-webgl"):t.getContext("webgl2")}function a(e){if(null!=e){var t=e.getExtension("WEBGL_lose_context");if(null==t)throw new Error("Extension WEBGL_lose_context not supported on this browser.");t.loseContext()}}function o(e){var t=i(e);return null!=t&&(a(t),!0)}function s(e){if(0===e)return 0;var t,n=i(e);return t=r(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:r(n,"EXT_disjoint_timer_query")?1:0,null!=n&&a(n),t}function u(e){if(0===e)return!1;var t=i(e);if(1===e){if(!r(t,"OES_texture_float"))return!1}else if(!r(t,"EXT_color_buffer_float"))return!1;var n=t.createFramebuffer(),o=t.createTexture();t.bindTexture(t.TEXTURE_2D,o);var s=2===e?t.RGBA32F:t.RGBA;t.texImage2D(t.TEXTURE_2D,0,s,1,1,0,t.RGBA,t.FLOAT,null),t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,o,0);var u=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;t.readPixels(0,0,1,1,t.RGBA,t.FLOAT,new Float32Array(4));var l=t.getError()===t.NO_ERROR;return a(t),u&&l}function l(e){if(e>0)return!1;if(2!==e)return!1;var t=i(e),n=r(t,"WEBGL_get_buffer_sub_data_async");return a(t),n}function c(){var e={};if("undefined"==typeof window)return e;var t=v.getQueryParams(window.location.search);if(b in t){var r={};t[b].split(",").forEach(function(e){var t=e.split(":"),n=t[0],i=t[1];r[n]=i}),n.URL_PROPERTIES.forEach(function(t){t.name in r&&(console.log("Setting feature override from URL "+t.name+": "+r[t.name]),t.type===d.NUMBER?e[t.name]=+r[t.name]:t.type===d.BOOLEAN?e[t.name]="true"===r[t.name]:t.type===d.STRING?e[t.name]=r[t.name]:console.warn("Unknown URL param: "+t.name+"."))})}return e}function p(){var e;if("undefined"!=typeof window)e=window;else{if(void 0===t)throw new Error("Could not find a global object");e=t}return e}var h=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var d,f=e("./device_util"),g=e("./doc"),m=e("./engine"),v=e("./util");!function(e){e[e.NUMBER=0]="NUMBER",e[e.BOOLEAN=1]="BOOLEAN",e[e.STRING=2]="STRING"}(d=n.Type||(n.Type={})),n.URL_PROPERTIES=[{name:"DEBUG",type:d.BOOLEAN},{name:"WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",type:d.NUMBER},{name:"WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",type:d.BOOLEAN},{name:"WEBGL_VERSION",type:d.NUMBER},{name:"WEBGL_FLOAT_TEXTURE_ENABLED",type:d.BOOLEAN},{name:"WEBGL_GET_BUFFER_SUB_DATA_ASYNC_EXTENSION_ENABLED",type:d.BOOLEAN},{name:"BACKEND",type:d.STRING}];var y=function(){function e(e){this.features={},this.registry={},null!=e&&(this.features=e),this.get("DEBUG")&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")}return e.setBackend=function(e,t){if(void 0===t&&(t=!1),!(e in n.ENV.registry))throw new Error("Backend type '"+e+"' not found in registry");n.ENV.initBackend(e,t)},e.getBackend=function(){return n.ENV.initDefaultBackend(),n.ENV.currentBackend},e.memory=function(){return n.ENV.engine.memory()},e.prototype.get=function(e){return e in this.features?this.features[e]:(this.features[e]=this.evaluateFeature(e),this.features[e])},e.prototype.set=function(e,t){this.features[e]=t},e.prototype.getBestBackendType=function(){var e=this;if(0===Object.keys(this.registry).length)throw new Error("No backend found in registry.");return Object.keys(this.registry).map(function(t){return{name:t,entry:e.registry[t]}}).sort(function(e,t){return t.entry.priority-e.entry.priority})[0].name},e.prototype.evaluateFeature=function(e){if("DEBUG"===e)return!1;if("BACKEND"===e)return this.getBestBackendType();if("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"===e){var t=this.get("WEBGL_VERSION");return 0===t?0:s(t)}if("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE"===e)return this.get("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!f.isMobile();if("WEBGL_VERSION"===e)return o(2)?2:o(1)?1:0;if("WEBGL_FLOAT_TEXTURE_ENABLED"===e)return u(this.get("WEBGL_VERSION"));if("WEBGL_GET_BUFFER_SUB_DATA_ASYNC_EXTENSION_ENABLED"===e)return l(this.get("WEBGL_VERSION"));throw new Error("Unknown feature "+e+".")},e.prototype.setFeatures=function(e){this.features=e},e.prototype.reset=function(){this.features=c(),null!=this.globalEngine&&(this.globalEngine.dispose(),this.globalEngine=null)},e.prototype.initBackend=function(e,t){void 0===t&&(t=!1),this.currentBackend=e,null!=this.globalEngine&&this.globalEngine.dispose();var r=n.ENV.findBackend(e);this.globalEngine=new m.Engine(r,t)},e.prototype.findBackend=function(e){return e in this.registry?this.registry[e].backend:null},e.prototype.registerBackend=function(e,t,n){void 0===n&&(n=1),e in this.registry&&console.warn(e+" backend was already registered");try{var r=t();return this.registry[e]={backend:r,priority:n},!0}catch(e){return console.warn(e.message),!1}},e.prototype.removeBackend=function(e){if(!(e in this.registry))throw new Error(e+" backend not found in registry");this.registry[e].backend.dispose(),delete this.registry[e]},Object.defineProperty(e.prototype,"engine",{get:function(){return this.initDefaultBackend(),this.globalEngine},enumerable:!0,configurable:!0}),e.prototype.initDefaultBackend=function(){null==this.globalEngine&&this.initBackend(n.ENV.get("BACKEND"),!1)},h([g.doc({heading:"Environment"})],e,"setBackend",null),h([g.doc({heading:"Environment"})],e,"getBackend",null),h([g.doc({heading:"Performance",subheading:"Memory"})],e,"memory",null),e}();n.Environment=y;var b="tfjsflags";n.ENV=function(){var e=p();return e.ENV=e.ENV||new y(c()),e.ENV}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./device_util":2,"./doc":3,"./engine":4,"./util":95}],6:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./gradients"),i=e("./tracking");n.tidy=i.Tracking.tidy,n.keep=i.Tracking.keep,n.dispose=i.Tracking.dispose,n.time=i.Tracking.time,n.grad=r.Gradients.grad,n.valueAndGrad=r.Gradients.valueAndGrad,n.grads=r.Gradients.grads,n.valueAndGrads=r.Gradients.valueAndGrads,n.variableGrads=r.Gradients.variableGrads,n.customGrad=r.Gradients.customGrad},{"./gradients":7,"./tracking":92}],7:[function(e,t,n){"use strict";function r(e){if(e.filter(function(e){return null==e}).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}var i=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var a=e("./doc"),o=e("./environment"),s=e("./globals"),u=e("./tensor"),l=e("./util"),c=function(){function e(){}return e.gradScope=function(e,t){return s.tidy(e,t,!0)},e.grad=function(e){return l.assert(l.isFunction(e),"The f passed in grad(f) must be a function"),function(t,n){l.assert(t instanceof u.Tensor,"The x passed in grad(f)(x) must be a tensor"),l.assert(null==n||n instanceof u.Tensor,"The dy passed in grad(f)(x, dy) must be a tensor");var i=o.ENV.engine.gradients(function(){return e(t)},[t],n),a=i.value,s=i.grads;return null!=n&&l.assertShapesMatch(a.shape,n.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),a.dispose(),r(s),s[0]}},e.grads=function(e){return l.assert(l.isFunction(e),"The f passed in grads(f) must be a function"),function(t,n){l.assert(Array.isArray(t)&&t.every(function(e){return e instanceof u.Tensor}),"The args passed in grads(f)(args) must be an array of tensors"),l.assert(null==n||n instanceof u.Tensor,"The dy passed in grads(f)(args, dy) must be a tensor");var i=o.ENV.engine.gradients(function(){return e.apply(void 0,t)},t,n),a=i.value,s=i.grads;return null!=n&&l.assertShapesMatch(a.shape,n.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),a.dispose(),r(s),s}},e.valueAndGrad=function(e){return l.assert(l.isFunction(e),"The f passed in valueAndGrad(f) must be a function"),function(t,n){l.assert(t instanceof u.Tensor,"The x passed in valueAndGrad(f)(x) must be a tensor"),l.assert(null==n||n instanceof u.Tensor,"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");var i=o.ENV.engine.gradients(function(){return e(t)},[t],n),a=i.grads,s=i.value;return r(a),{grad:a[0],value:s}}},e.valueAndGrads=function(e){return l.assert(l.isFunction(e),"The f passed in valueAndGrads(f) must be a function"),function(t,n){l.assert(Array.isArray(t)&&t.every(function(e){return e instanceof u.Tensor}),"The args passed in valueAndGrads(f)(args) must be array of tensors"),l.assert(null==n||n instanceof u.Tensor,"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");var i=o.ENV.engine.gradients(function(){return e.apply(void 0,t)},t,n);return null!=n&&l.assertShapesMatch(i.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),r(i.grads),i}},e.variableGrads=function(e,t){if(l.assert(l.isFunction(e),"The f passed in variableGrads(f) must be a function"),l.assert(null==t||Array.isArray(t)&&t.every(function(e){return e instanceof u.Variable}),"The varList passed in variableGrads(f, varList) must be an array of variables"),null==t){t=[];for(var n in o.ENV.engine.registeredVariables)t.push(o.ENV.engine.registeredVariables[n])}var r=t.length;t=t.filter(function(e){return e.trainable}),l.assert(t.length>0,"variableGrads() expects at least one of the input variables to be trainable, but none of the "+r+" variables is trainable.");var i=o.ENV.engine.gradients(e,t,null,!0),a=i.value,s=i.grads;l.assert(s.some(function(e){return null!=e}),"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),l.assert(0===a.rank,"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+a.rank+" tensor");var c={};return t.forEach(function(e,t){null!=s[t]&&(c[e.name]=s[t])}),{value:a,grads:c}},e.customGrad=function(e){return o.ENV.engine.customGrad(e)},i([a.doc({heading:"Training",subheading:"Gradients"})],e,"grad",null),i([a.doc({heading:"Training",subheading:"Gradients"})],e,"grads",null),i([a.doc({heading:"Training",subheading:"Gradients"})],e,"valueAndGrad",null),i([a.doc({heading:"Training",subheading:"Gradients"})],e,"valueAndGrads",null),i([a.doc({heading:"Training",subheading:"Gradients"})],e,"variableGrads",null),i([a.doc({heading:"Training",subheading:"Gradients"})],e,"customGrad",null),e}();n.Gradients=c},{"./doc":3,"./environment":5,"./globals":6,"./tensor":89,"./util":95}],8:[function(e,t,n){"use strict";function r(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}Object.defineProperty(n,"__esModule",{value:!0}),e("./kernels/backend_webgl"),e("./kernels/backend_cpu");var i=e("./browser_util"),a=e("./environment");n.environment=a;var o=e("./environment"),s=e("./kernels/webgl/gpgpu_util"),u=e("./kernels/webgl/webgl_util"),l=e("./test_util");n.test_util=l;var c=e("./util");n.util=c;var p=e("./version");n.version_core=p.version;var h=e("./optimizers/adadelta_optimizer");n.AdadeltaOptimizer=h.AdadeltaOptimizer;var d=e("./optimizers/adagrad_optimizer");n.AdagradOptimizer=d.AdagradOptimizer;var f=e("./optimizers/adam_optimizer");n.AdamOptimizer=f.AdamOptimizer;var g=e("./optimizers/adamax_optimizer");n.AdamaxOptimizer=g.AdamaxOptimizer;var m=e("./optimizers/momentum_optimizer");n.MomentumOptimizer=m.MomentumOptimizer;var v=e("./optimizers/optimizer");n.Optimizer=v.Optimizer;var y=e("./optimizers/rmsprop_optimizer");n.RMSPropOptimizer=y.RMSPropOptimizer;var b=e("./optimizers/sgd_optimizer");n.SGDOptimizer=b.SGDOptimizer;var w=e("./tensor");n.Tensor=w.Tensor,n.TensorBuffer=w.TensorBuffer,n.variable=w.variable,n.Variable=w.Variable;var x=e("./types");n.Rank=x.Rank;var A=e("./weights_loader");n.loadWeights=A.loadWeights,r(e("./ops/ops"));var E=e("./ops/loss_ops");n.Reduction=E.Reduction,r(e("./train")),r(e("./globals"));var _=e("./environment");n.ENV=_.ENV,n.Environment=_.Environment,n.setBackend=o.Environment.setBackend,n.getBackend=o.Environment.getBackend,n.memory=o.Environment.memory;var T=e("./doc");n.doc=T.doc,n.nextFrame=i.BrowserUtil.nextFrame,n.webgl={webgl_util:u,gpgpu_util:s}},{"./browser_util":1,"./doc":3,"./environment":5,"./globals":6,"./kernels/backend_cpu":9,"./kernels/backend_webgl":11,"./kernels/webgl/gpgpu_util":25,"./kernels/webgl/webgl_util":45,"./ops/loss_ops":59,"./ops/ops":66,"./optimizers/adadelta_optimizer":78,"./optimizers/adagrad_optimizer":79,"./optimizers/adam_optimizer":80,"./optimizers/adamax_optimizer":81,"./optimizers/momentum_optimizer":82,"./optimizers/optimizer":83,"./optimizers/rmsprop_optimizer":85,"./optimizers/sgd_optimizer":86,"./tensor":89,"./test_util":91,"./train":93,"./types":94,"./util":95,"./version":96,"./weights_loader":97}],9:[function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(o=a[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(a,n[1])).done)return o;switch(a=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]f&&(f=y,g=v)}l[h]=g}return o},e.prototype.equal=function(e,t){return this.broadcastedBinaryOp(e,t,"bool",function(e,t){return e===t?1:0})},e.prototype.notEqual=function(e,t){return this.broadcastedBinaryOp(e,t,"bool",function(e,t){return e!==t?1:0})},e.prototype.less=function(e,t){return this.broadcastedBinaryOp(e,t,"bool",function(e,t){return et?1:0})},e.prototype.greaterEqual=function(e,t){return this.broadcastedBinaryOp(e,t,"bool",function(e,t){return e>=t?1:0})},e.prototype.logicalNot=function(e){for(var t=e.dataSync(),n=new Int32Array(t.length),r=0;r1||1===t.rank?1:t.shape[1],h=0;h=0&&t>=0?n:(n+t)%t})},e.prototype.max=function(e,t){s.assertAxesAreInnerMostDims("max",t,e.rank);for(var n=s.computeOutAndReduceShapes(e.shape,t),r=n[0],i=n[1],a=c.zeros(r,e.dtype),o=m.sizeFromShape(i),u=a.dataSync(),l=e.dataSync(),p=0;pd&&(d=g)}u[p]=d}return a},e.prototype.maximum=function(e,t){return this.broadcastedBinaryOp(e,t,e.dtype,function(e,t){return Math.max(e,t)})},e.prototype.squaredDifference=function(e,t){return this.broadcastedBinaryOp(e,t,e.dtype,function(e,t){var n=e-t;return n*n})},e.prototype.ceil=function(e){for(var t=e.dataSync(),n=new Float32Array(t.length),r=0;r0?n[r]=1:n[r]=0;return f.Tensor.make(e.shape,{values:n})},e.prototype.round=function(e){for(var t=e.dataSync(),n=new Float32Array(t.length),r=0;r.5?n[r]=Math.ceil(t[r]):n[r]=i%2==0?i:i+1}return f.Tensor.make(e.shape,{values:n})},e.prototype.exp=function(e){for(var t=e.dataSync(),n=new Float32Array(t.length),r=0;r=0?i:Math.exp(i)-1}return f.Tensor.make(e.shape,{values:t})},e.prototype.eluDer=function(e,t){for(var n=new Float32Array(t.size),r=t.dataSync(),i=e.dataSync(),a=0;a=1?i[a]:i[a]*(o+1)}return f.Tensor.make(t.shape,{values:n})},e.prototype.selu=function(e){for(var t=h.SELU_SCALEALPHA,n=h.SELU_SCALE,r=new Float32Array(e.size),i=e.dataSync(),a=0;a=0?n*o:t*(Math.exp(o)-1)}return f.Tensor.make(e.shape,{values:r})},e.prototype.clip=function(e,t,n){for(var r=new Float32Array(e.size),i=e.dataSync(),a=0;a-t,o=r[i]0?1:t}return f.Tensor.make(e.shape,{values:n})},e.prototype.conv2d=function(e,t,n){for(var r=n.filterHeight,i=n.filterWidth,a=n.dilationHeight,o=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,l=c.buffer(n.outShape,e.dtype),p=0;p=n.inHeight))for(var w=0;w=n.inWidth))for(var A=0;A=n.inHeight))for(var A=0;A=n.inWidth||(b+=e.get(h,x,E,d)*t.get(w,A,d,y))}}p.set(b,h,f,m,d*l+y)}return p.toTensor()},e.prototype.tile=function(e,t){for(var n=new Array(e.rank),r=0;rx?x=S:"avg"===n&&(A+=S,E++)}if(isNaN(x))break}s.set("avg"===n?A/E:x,p,d,v,h)}return s.toTensor()},e.prototype.maxPool=function(e,t){return this.pool(e,t,"max")},e.prototype.maxPoolPositions=function(e,t){for(var n=c.buffer(t.outShape,"int32"),r=t.strideHeight,i=t.strideWidth,a=t.filterHeight,o=t.filterWidth,s=t.padInfo.top,u=t.padInfo.left,l=0;lw&&(w=S,x=E*o+T)}n.set(x,l,h,m,p)}return n.toTensor()},e.prototype.maxPoolBackprop=function(e,t,n,r){for(var i=this.maxPoolPositions(t,r),a=r.strideHeight,o=r.strideWidth,s=r.filterHeight,u=r.filterWidth,l=u-1-r.padInfo.left,p=s-1-r.padInfo.top,h=c.buffer(t.shape,"float32"),d=0;d=r.outHeight||Math.floor(x)!==x))for(var A=0;A=r.outWidth||Math.floor(E)!==E)){var _=s*u-1-i.get(d,x,E,f)===w*u+A?1:0;0!==_&&(b+=e.get(d,x,E,f)*_)}}}h.set(b,d,g,m,f)}return h.toTensor()},e.prototype.avgPoolBackprop=function(e,t,n){for(var r=n.strideHeight,i=n.strideWidth,a=n.filterHeight,o=n.filterWidth,s=o-1-n.padInfo.left,u=a-1-n.padInfo.top,l=c.buffer(t.shape,"float32"),p=1/(a*o),h=0;h=n.outHeight||Math.floor(w)!==w))for(var x=0;x=n.outWidth||Math.floor(A)!==A||(y+=e.get(h,w,A,d))}}l.set(y*p,h,f,g,d)}return l.toTensor()},e.prototype.cast=function(e,t){return v.castTensor(e,t,this)},e.prototype.reshape=function(e,t){return v.reshapeTensor(e,t)},e.prototype.avgPool=function(e,t){return this.pool(e,t,"avg").toFloat()},e.prototype.resizeBilinear=function(e,t,n,r){for(var i=e.shape,a=i[0],o=i[1],s=i[2],u=i[3],l=c.buffer([a,t,n,u],e.dtype),p=r?[o-1,s-1]:[o,s],h=r?[t-1,n-1]:[t,n],d=0;d0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]0?this.gpgpu.beginQuery():{startMs:performance.now(),endMs:null}},e.prototype.endTimer=function(e){return s.ENV.get("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(this.gpgpu.endQuery(),e):(e.endMs=performance.now(),e)},e.prototype.getQueryTime=function(e){return a(this,void 0,void 0,function(){var t;return o(this,function(n){return s.ENV.get("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?[2,this.gpgpu.pollQueryTime(e)]:(t=e,[2,t.endMs-t.startMs])})})},e.prototype.disposeData=function(e){if(this.texData.has(e)){var t=this.texData.get(e),n=t.texture,r=t.texShape,i=t.texType;null!=n&&this.textureManager.releaseTexture(n,r,i),this.texData.delete(e)}},e.prototype.getTexture=function(e){return this.uploadToGPU(e),this.texData.get(e).texture},e.prototype.getTextureData=function(e){return this.uploadToGPU(e),this.texData.get(e)},e.prototype.getGPGPUContext=function(){return this.gpgpu},e.prototype.slice=function(e,t,n){var r=new U.SliceProgram(n),i=r.getCustomSetupFunc(t);return this.compileAndRun(r,[e],null,i)},e.prototype.reverse=function(e,t){var n=new B.ReverseProgram(e.shape,t);return this.compileAndRun(n,[e])},e.prototype.concat=function(e,t){var n=new x.ConcatProgram(e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.neg=function(e){var t=new K.UnaryOpProgram(e.shape,H.NEG);return this.compileAndRun(t,[e])},e.prototype.matMul=function(e,t,n,r){var i=new I.MatMulProgram(e.shape,t.shape,n,r);return this.compileAndRun(i,[e,t])},e.prototype.multiply=function(e,t){var n=new b.BinaryOpProgram(y.MUL,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,h.upcastType(e.dtype,t.dtype));return this.compileAndRun(n,[e,t],r)},e.prototype.batchNormalization=function(e,t,n,r,i,a){var o=[e,t,n],s=null;null!=a&&(s=a.shape,o.push(a));var u=null;null!=i&&(u=i.shape,o.push(i));var l=new v.BatchNormProgram(e.shape,t.shape,n.shape,s,u,r);return this.compileAndRun(l,o)},e.prototype.localResponseNormalization4D=function(e,t,n,r,i){var a=new R.LRNProgram(e.shape,t,n,r,i);return this.compileAndRun(a,[e])},e.prototype.tile=function(e,t){var n=new W.TileProgram(e.shape,t);return this.compileAndRun(n,[e])},e.prototype.pad=function(e,t,n){var r=new D.PadProgram(e.shape,t,n);return this.compileAndRun(r,[e])},e.prototype.transpose=function(e,t){var n=new q.TransposeProgram(e.shape,t);return this.compileAndRun(n,[e])},e.prototype.gather=function(e,t,n){var r=new S.GatherProgram(e.shape,t.size,n);return this.compileAndRun(r,[e,t])},e.prototype.reduce=function(e,t,n){var r=e.shape[0],i=e.shape[1],a={windowSize:c.computeOptimalWindowSize(i),inSize:i,batchSize:r},o=new L.ReduceProgram(a,t),s=o.outputShape,u=s[0],l=s[1],p=this.makeOutputArray([u,l],n);return this.compileAndRun(o,[e],p),1===p.shape[1]?p:this.reduce(p,t,n)},e.prototype.argReduce=function(e,t,n){void 0===n&&(n=null);var r=e.shape[0],i=e.shape[1];null!=n&&(r=n.shape[0],i=n.shape[1]);var a={windowSize:c.computeOptimalWindowSize(i),inSize:i,batchSize:r},o=new g.ArgMinMaxProgram(a,t,null==n),s=o.outputShape,u=s[0],l=s[1],p=this.makeOutputArray([u,l],"int32"),h=[e];return null!=n&&h.push(n),this.compileAndRun(o,h,p),1===p.shape[1]?p:this.argReduce(e,t,p)},e.prototype.sum=function(e,t){u.assertAxesAreInnerMostDims("sum",t,e.rank);var n=u.computeOutAndReduceShapes(e.shape,t),r=n[0],i=n[1],a=d.sizeFromShape(i),o=e.as2D(-1,a),s=h.sumOutType(e.dtype);return this.reduce(o,"sum",s).reshape(r)},e.prototype.argMin=function(e,t){var n=[t];u.assertAxesAreInnerMostDims("argMin",n,e.rank);var r=u.computeOutAndReduceShapes(e.shape,n),i=r[0],a=r[1],o=d.sizeFromShape(a),s=e.as2D(-1,o);return this.argReduce(s,"min").reshape(i)},e.prototype.argMax=function(e,t){var n=[t];u.assertAxesAreInnerMostDims("argMax",n,e.rank);var r=u.computeOutAndReduceShapes(e.shape,n),i=r[0],a=r[1],o=d.sizeFromShape(a),s=e.as2D(-1,o);return this.argReduce(s,"max").reshape(i)},e.prototype.equal=function(e,t){var n=new b.BinaryOpProgram(y.EQUAL,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.notEqual=function(e,t){var n=new b.BinaryOpProgram(y.NOT_EQUAL,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.less=function(e,t){var n=new b.BinaryOpProgram(y.LESS,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.lessEqual=function(e,t){var n=new b.BinaryOpProgram(y.LESS_EQUAL,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.greater=function(e,t){var n=new b.BinaryOpProgram(y.GREATER,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.greaterEqual=function(e,t){var n=new b.BinaryOpProgram(y.GREATER_EQUAL,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.logicalNot=function(e){var t=new K.UnaryOpProgram(e.shape,H.LOGICAL_NOT);return this.compileAndRun(t,[e])},e.prototype.logicalAnd=function(e,t){var n=new b.BinaryOpProgram(y.LOGICAL_AND,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.logicalOr=function(e,t){var n=new b.BinaryOpProgram(y.LOGICAL_OR,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,"bool");return this.compileAndRun(n,[e,t],r)},e.prototype.where=function(e,t,n,r){var i=new k.WhereProgram(e.rank,t.shape,t.rank),a=this.makeOutputArray(i.outputShape,r);return this.compileAndRun(i,[e,t,n],a)},e.prototype.topKValues=function(e,t){throw new Error("topKValues GPU not yet implemented!")},e.prototype.topKIndices=function(e,t){throw new Error("topKIndices GPU not yet implemented!")},e.prototype.min=function(e,t){u.assertAxesAreInnerMostDims("min",t,e.rank);var n=u.computeOutAndReduceShapes(e.shape,t),r=n[0],i=n[1],a=d.sizeFromShape(i),o=e.as2D(-1,a);return this.reduce(o,"min",o.dtype).reshape(r)},e.prototype.minimum=function(e,t){var n=new b.BinaryOpProgram(y.MIN,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.mod=function(e,t){var n=new b.BinaryOpProgram(y.MOD,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.max=function(e,t){u.assertAxesAreInnerMostDims("max",t,e.rank);var n=u.computeOutAndReduceShapes(e.shape,t),r=n[0],i=n[1],a=d.sizeFromShape(i),o=e.as2D(-1,a);return this.reduce(o,"max",o.dtype).reshape(r)},e.prototype.maximum=function(e,t){var n=new b.BinaryOpProgram(y.MAX,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.squaredDifference=function(e,t){var n=new b.BinaryOpProgram(y.SQUARED_DIFFERENCE,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.divide=function(e,t){var n,r;"int32"===e.dtype&&"int32"===t.dtype?(n=y.INT_DIV,r="int32"):(n=y.DIV,r="float32");var i=new b.BinaryOpProgram(n,e.shape,t.shape),a=this.makeOutputArray(i.outputShape,r);return this.compileAndRun(i,[e,t],a)},e.prototype.add=function(e,t){var n=new b.BinaryOpProgram(y.ADD,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,h.upcastType(e.dtype,t.dtype));return this.compileAndRun(n,[e,t],r)},e.prototype.subtract=function(e,t){var n=new b.BinaryOpProgram(y.SUB,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,h.upcastType(e.dtype,t.dtype));return this.compileAndRun(n,[e,t],r)},e.prototype.pow=function(e,t){var n=new b.BinaryOpProgram(y.POW,e.shape,t.shape),r=this.makeOutputArray(n.outputShape,h.upcastType(e.dtype,t.dtype));return this.compileAndRun(n,[e,t],r)},e.prototype.ceil=function(e){var t=new K.UnaryOpProgram(e.shape,H.CEIL);return this.compileAndRun(t,[e])},e.prototype.floor=function(e){var t=new K.UnaryOpProgram(e.shape,H.FLOOR);return this.compileAndRun(t,[e])},e.prototype.sign=function(e){var t=new K.UnaryOpProgram(e.shape,H.SIGN);return this.compileAndRun(t,[e])},e.prototype.round=function(e){var t=new K.UnaryOpProgram(e.shape,H.ROUND);return this.compileAndRun(t,[e])},e.prototype.exp=function(e){var t=new K.UnaryOpProgram(e.shape,H.EXP);return this.compileAndRun(t,[e])},e.prototype.expm1=function(e){var t=new K.UnaryOpProgram(e.shape,H.EXPM1);return this.compileAndRun(t,[e])},e.prototype.log=function(e){var t=new K.UnaryOpProgram(e.shape,H.LOG);return this.compileAndRun(t,[e])},e.prototype.log1p=function(e){var t=new K.UnaryOpProgram(e.shape,H.LOG1P);return this.compileAndRun(t,[e])},e.prototype.sqrt=function(e){var t=new K.UnaryOpProgram(e.shape,H.SQRT);return this.compileAndRun(t,[e])},e.prototype.rsqrt=function(e){var t=new K.UnaryOpProgram(e.shape,H.RSQRT);return this.compileAndRun(t,[e])},e.prototype.square=function(e){var t=new K.UnaryOpProgram(e.shape,H.SQUARE);return this.compileAndRun(t,[e])},e.prototype.reciprocal=function(e){var t=new K.UnaryOpProgram(e.shape,H.RECIPROCAL);return this.compileAndRun(t,[e])},e.prototype.relu=function(e){var t=new K.UnaryOpProgram(e.shape,H.RELU);return this.compileAndRun(t,[e])},e.prototype.elu=function(e){var t=new K.UnaryOpProgram(e.shape,H.ELU);return this.compileAndRun(t,[e])},e.prototype.eluDer=function(e,t){var n=new b.BinaryOpProgram(y.ELU_DER,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.selu=function(e){var t=new K.UnaryOpProgram(e.shape,H.SELU);return this.compileAndRun(t,[e])},e.prototype.int=function(e){var t=new K.UnaryOpProgram(e.shape,H.TO_INT),n=this.makeOutputArray(t.outputShape,"int32");return this.compileAndRun(t,[e],n)},e.prototype.clip=function(e,t,n){var r=new w.ClipProgram(e.shape,t,n);return this.compileAndRun(r,[e])},e.prototype.abs=function(e){var t=new K.UnaryOpProgram(e.shape,H.ABS);return this.compileAndRun(t,[e])},e.prototype.sigmoid=function(e){var t=new K.UnaryOpProgram(e.shape,H.SIGMOID);return this.compileAndRun(t,[e])},e.prototype.softplus=function(e){var t=new K.UnaryOpProgram(e.shape,H.SOFTPLUS);return this.compileAndRun(t,[e])},e.prototype.sin=function(e){var t=new K.UnaryOpProgram(e.shape,H.SIN);return this.compileAndRun(t,[e])},e.prototype.cos=function(e){var t=new K.UnaryOpProgram(e.shape,H.COS);return this.compileAndRun(t,[e])},e.prototype.tan=function(e){var t=new K.UnaryOpProgram(e.shape,H.TAN);return this.compileAndRun(t,[e])},e.prototype.asin=function(e){var t=new K.UnaryOpProgram(e.shape,H.ASIN);return this.compileAndRun(t,[e])},e.prototype.acos=function(e){var t=new K.UnaryOpProgram(e.shape,H.ACOS);return this.compileAndRun(t,[e])},e.prototype.atan=function(e){var t=new K.UnaryOpProgram(e.shape,H.ATAN);return this.compileAndRun(t,[e])},e.prototype.atan2=function(e,t){var n=new b.BinaryOpProgram(y.ATAN2,e.shape,t.shape);return this.compileAndRun(n,[e,t])},e.prototype.sinh=function(e){var t=new K.UnaryOpProgram(e.shape,H.SINH);return this.compileAndRun(t,[e])},e.prototype.cosh=function(e){var t=new K.UnaryOpProgram(e.shape,H.COSH);return this.compileAndRun(t,[e])},e.prototype.tanh=function(e){var t=new K.UnaryOpProgram(e.shape,H.TANH);return this.compileAndRun(t,[e])},e.prototype.asinh=function(e){var t=new K.UnaryOpProgram(e.shape,H.ASINH);return this.compileAndRun(t,[e])},e.prototype.acosh=function(e){var t=new K.UnaryOpProgram(e.shape,H.ACOSH);return this.compileAndRun(t,[e])},e.prototype.atanh=function(e){var t=new K.UnaryOpProgram(e.shape,H.ATANH);return this.compileAndRun(t,[e])},e.prototype.erf=function(e){var t=new K.UnaryOpProgram(e.shape,H.ERF);return this.compileAndRun(t,[e])},e.prototype.step=function(e,t){var n=new K.UnaryOpProgram(e.shape,H.STEP(t));return this.compileAndRun(n,[e])},e.prototype.conv2d=function(e,t,n){var r=new E.Conv2DProgram(n);return this.compileAndRun(r,[e,t])},e.prototype.conv2dDerInput=function(e,t,n){var r=new A.Conv2DDerInputProgram(n);return this.compileAndRun(r,[e,t])},e.prototype.conv2dDerFilter=function(e,t,n){var r=new A.Conv2DDerFilterProgram(n);return this.compileAndRun(r,[e,t])},e.prototype.depthwiseConv2D=function(e,t,n){var r=new _.DepthwiseConv2DProgram(n);return this.compileAndRun(r,[e,t])},e.prototype.maxPool=function(e,t){var n=new P.Pool2DProgram(t,"max",!1),r=this.makeOutputArray(n.outputShape,e.dtype);return this.compileAndRun(n,[e],r)},e.prototype.avgPool=function(e,t){var n=new P.Pool2DProgram(t,"avg",!1),r=this.makeOutputArray(n.outputShape,"float32");return this.compileAndRun(n,[e],r)},e.prototype.maxPoolBackprop=function(e,t,n,r){var i=new P.Pool2DProgram(r,"max",!0),a=this.compileAndRun(i,[t]),o=new N.MaxPool2DBackpropProgram(r),s=this.makeOutputArray(o.outputShape,t.dtype),u=this.compileAndRun(o,[e,a],s);return a.dispose(),u},e.prototype.avgPoolBackprop=function(e,t,n){var r=new m.AvgPool2DBackpropProgram(n),i=this.makeOutputArray(r.outputShape,t.dtype);return this.compileAndRun(r,[e],i)},e.prototype.cast=function(e,t){return f.castTensor(e,t,this)},e.prototype.reshape=function(e,t){return f.reshapeTensor(e,t)},e.prototype.resizeBilinear=function(e,t,n,r){var i=new F.ResizeBilinearProgram(e.shape,t,n,r);return this.compileAndRun(i,[e])},e.prototype.resizeNearestNeighbor=function(e,t,n,r){var i=new V.ResizeNearestNeighborProgram(e.shape,t,n,r);return this.compileAndRun(i,[e])},e.prototype.multinomial=function(e,t,n,r){var i=t?e:l.softmax(e),a=i.shape[0],o=i.shape[1],s=new z.MultinomialProgram(a,o,n),u=this.makeOutputArray(s.outputShape,"int32"),c=s.getCustomSetupFunc(r);return this.compileAndRun(s,[i],u,c)},e.prototype.oneHot=function(e,t,n,r){var i=new M.OneHotProgram(e.size,t,n,r);return this.compileAndRun(i,[e])},e.prototype.makeOutputArray=function(e,t){return p.Tensor.make(e,{},t)},e.prototype.compileAndRun=function(e,t,n,r){var i=this;null==n&&(n=this.makeOutputArray(e.outputShape,t[0].dtype));var a=t.map(function(e){return i.uploadToGPU(e.dataId),{tensor:e,texData:i.texData.get(e.dataId)}});this.uploadToGPU(n.dataId);var o,s={tensor:n,texData:this.texData.get(n.dataId)},u=O.makeShaderKey(e,a,s),l=this.getAndSaveBinary(u,function(){return O.compileProgram(i.gpgpu,e,a,s)}),c=null!=this.activeTimers;return c&&(o=this.startTimer()),O.runProgram(l,a,s,r),c&&(o=this.endTimer(o),this.activeTimers.push(this.getQueryTime(o))),n},e.prototype.getAndSaveBinary=function(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]},e.prototype.getTextureManager=function(){return this.textureManager},e.prototype.dispose=function(){if(!this.disposed){for(var e in this.binaryCache)this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram);this.textureManager.dispose(),this.canvas.remove(),this.gpgpuCreatedLocally&&this.gpgpu.dispose(),this.disposed=!0}},e.prototype.throwIfNoData=function(e){if(!this.texData.has(e))throw new Error("WebGL backend: No data found for this tensor. Did you change your backend in the middle of the program? New backends can't use Tensors created with previous backends")},e.prototype.uploadToGPU=function(e){this.throwIfNoData(e);var t=this.texData.get(e),n=t.shape,r=t.values,a=t.texture,o=(t.dtype,t.texType);if(null==a){var s,u=null!=this.activeTimers;u&&(s=performance.now());var l=X.getTextureShapeFromLogicalShape(this.gpgpu.gl,n);t.texShape=l;var c=this.textureManager.acquireTexture(l,o);t.texture=c,null!=r&&(this.gpgpu.uploadMatrixToTexture(c,l[0],l[1],i(r)),t.values=null,u&&(this.uploadWaitMs+=performance.now()-s))}},e.prototype.cacheOnCPU=function(e,t){var n=this.delayedStorage,i=this.texData.get(e),a=i.texture,o=i.texShape,s=i.dtype,u=i.texType;n&&null!=a&&(this.textureManager.releaseTexture(a,o,u),i.texture=null,i.texShape=null),null!=t&&(i.values=r(t,s))},e}();n.MathBackendWebGL=Y,s.ENV.registerBackend("webgl",function(){return new Y},2)},{"../environment":5,"../ops/axis_util":47,"../ops/ops":66,"../ops/reduce_util":69,"../tensor":89,"../types":94,"../util":95,"./backend_util":10,"./webgl/argminmax_gpu":12,"./webgl/avg_pool_backprop_gpu":13,"./webgl/batchnorm_gpu":14,"./webgl/binaryop_gpu":15,"./webgl/clip_gpu":16,"./webgl/concat_gpu":17,"./webgl/conv_backprop_gpu":18,"./webgl/conv_gpu":19,"./webgl/conv_gpu_depthwise":20,"./webgl/from_pixels_gpu":21,"./webgl/gather_gpu":22,"./webgl/gpgpu_context":23,"./webgl/gpgpu_math":24,"./webgl/logical_gpu":26,"./webgl/lrn_gpu":27,"./webgl/max_pool_backprop_gpu":28,"./webgl/mulmat_gpu":29,"./webgl/multinomial_gpu":30,"./webgl/onehot_gpu":31,"./webgl/pad_gpu":32,"./webgl/pool_gpu":33,"./webgl/reduce_gpu":34,"./webgl/resize_bilinear_gpu":35,"./webgl/resize_nearest_neighbor_gpu":36,"./webgl/reverse_gpu":37,"./webgl/slice_gpu":39,"./webgl/tex_util":40,"./webgl/texture_manager":41,"./webgl/tile_gpu":42,"./webgl/transpose_gpu":43,"./webgl/unaryop_gpu":44,"./webgl/webgl_util":45}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n){this.variableNames=["A"];var r=e.windowSize,i=e.batchSize,a=e.inSize,o=Math.ceil(a/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[i,o];var s="max"===t?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+r+";\n\n int bestIndex = 0;\n float bestValue = getA(batch, inOffset);\n\n for (int i = 0; i < "+r+"; i++) {\n int inIdx = "+u+";\n float candidate = getA(batch, inIdx);\n if (candidate "+s+" bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n "}}();n.ArgMinMaxProgram=r},{}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,i=e.strideWidth,a=t-1-e.padInfo.top,o=n-1-e.padInfo.left,s=1/(t*n);this.userCode="\n const ivec2 pads = ivec2("+a+", "+o+");\n const float avgMultiplier = float("+s+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n "}}();n.AvgPool2DBackpropProgram=r},{}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("../../ops/broadcast_util"),i=function(){return function(e,t,n,i,a,o){this.outputShape=[],this.supportsBroadcasting=!0,this.variableNames=["x","mean","variance"],r.assertAndGetBroadcastShape(e,t),r.assertAndGetBroadcastShape(e,n);var s="0.0";null!=i&&(r.assertAndGetBroadcastShape(e,i),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");var u="1.0";null!=a&&(r.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=e,this.userCode="\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = "+s+";\n float scale = "+u+";\n float inv = scale * inversesqrt(variance + float("+o+"));\n setOutput((x - mean) * inv + offset);\n }\n "}}();n.BatchNormProgram=i},{"../../ops/broadcast_util":50}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("../../ops/broadcast_util"),i="\n if (isNaN(a)) return a;\n if (isNaN(b)) return b;\n";n.ADD="return a + b;",n.SUB="return a - b;",n.MUL="return a * b;",n.DIV="return a / b;",n.INT_DIV="\n float resultSign = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n int result = ia / ib;\n int amodb = ia - ib * result;\n\n if (resultSign < 0.0 && amodb != 0) {\n result -= 1;\n }\n return float(result);\n",n.POW="\n return (round(mod(b, 2.0)) == 0 || round(mod(b, 2.0)) == 2) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",n.SQUARED_DIFFERENCE="return (a - b) * (a - b);",n.EQUAL="return float(a == b);",n.NOT_EQUAL="return float(a != b);",n.LESS="return float(a < b);",n.LESS_EQUAL="return float(a <= b);",n.GREATER="return float(a > b);",n.GREATER_EQUAL="return float(a >= b);",n.LOGICAL_AND="return float(a >= 1.0 && b >= 1.0);",n.LOGICAL_OR="return float(a >= 1.0 || b >= 1.0);",n.MAX=i+"\n return max(a, b);\n",n.MIN=i+"\n return min(a, b);\n",n.MOD="return mod(a, b);",n.ATAN2=i+"\n return atan(a, b);\n",n.ELU_DER="return (b >= 1.0) ? a : a * (b + 1.0);";var a=function(){return function(e,t,n){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.outputShape=r.assertAndGetBroadcastShape(t,n),this.userCode="\n float binaryOperation(float a, float b) {\n "+e+"\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n "}}();n.BinaryOpProgram=a},{"../../ops/broadcast_util":50}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n){this.variableNames=["A"],this.outputShape=e;var r=t.toFixed(20),i=n.toFixed(20);this.userCode="\n void main() {\n float value = getAAtOutCoords();\n if (isNaN(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, "+r+", "+i+"));\n }\n "}}();n.ClipProgram=r},{}],17:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("../../ops/concat_util"),i=function(){return function(e,t){this.variableNames=["A","B"],this.outputShape=[],this.outputShape=r.computeOutShape(e,t,1),this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n float value = 0.0;\n if (yC < "+e[1]+") {\n value = getA(yR, yC);\n } else {\n yC -= "+e[1]+";\n value = getB(yR, yC);\n }\n\n setOutput(value);\n }\n "}}();n.ConcatProgram=i},{"../../ops/concat_util":53}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,i=e.padInfo.left;this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < "+e.batchSize+"; b++) {\n for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n int xR = wR + yR * "+t+" - "+r+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n int xC = wC + yC * "+n+" - "+i+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n "}}();n.Conv2DDerFilterProgram=r;var i=function(){return function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,i=e.strideWidth,a=t-1-e.padInfo.top,o=n-1-e.padInfo.left;this.userCode="\n const ivec2 pads = ivec2("+a+", "+o+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = "+t+" - 1 - wR;\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = "+n+" - 1 - wC;\n\n for (int d2 = 0; d2 < "+e.outChannels+"; d2++) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n "}}();n.Conv2DDerInputProgram=i},{}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.padInfo.top,n=e.padInfo.left,r=e.strideHeight,i=e.strideWidth,a=e.dilationHeight,o=e.dilationWidth,s=e.filterHeight,u=e.filterWidth,l=4*Math.floor(e.inChannels/4),c=e.inChannels%4;this.userCode="\n const ivec2 strides = ivec2("+r+", "+i+");\n const ivec2 pads = ivec2("+t+", "+n+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+s+"; wR++) {\n int xR = xRCorner + wR * "+a+";\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+u+"; wC++) {\n int xC = xCCorner + wC * "+o+";\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n for (int d1 = 0; d1 < "+l+"; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if ("+(1===c)+") {\n dotProd +=\n getX(batch, xR, xC, "+l+") *\n getW(wR, wC, "+l+", d2);\n } else if ("+(2===c)+") {\n vec2 xValues = vec2(\n getX(batch, xR, xC, "+l+"),\n getX(batch, xR, xC, "+l+" + 1)\n );\n vec2 wValues = vec2(\n getW(wR, wC, "+l+", d2),\n getW(wR, wC, "+l+" + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if ("+(3===c)+") {\n vec3 xValues = vec3(\n getX(batch, xR, xC, "+l+"),\n getX(batch, xR, xC, "+l+" + 1),\n getX(batch, xR, xC, "+l+" + 2)\n );\n vec3 wValues = vec3(\n getW(wR, wC, "+l+", d2),\n getW(wR, wC, "+l+" + 1, d2),\n getW(wR, wC, "+l+" + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n setOutput(dotProd);\n }\n "}}();n.Conv2DProgram=r},{}],20:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.inHeight,n=e.inWidth,r=e.padInfo.top,i=e.padInfo.left,a=e.strideHeight,o=e.strideWidth,s=e.dilationHeight,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=e.outChannels/e.inChannels;this.userCode="\n const ivec2 strides = ivec2("+a+", "+o+");\n const ivec2 pads = ivec2("+r+", "+i+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / "+p+";\n int q = d2 - d1 * "+p+";\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TODO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < "+l+"; wR++) {\n int xR = xRCorner + wR * "+s+";\n\n if (xR < 0 || xR >= "+t+") {\n continue;\n }\n\n for (int wC = 0; wC < "+c+"; wC++) {\n int xC = xCCorner + wC * "+u+";\n\n if (xC < 0 || xC >= "+n+") {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n setOutput(dotProd);\n }\n "}}();n.DepthwiseConv2DProgram=r},{}],21:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["A"];var t=e[0],n=e[1];this.outputShape=e,this.userCode="\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+n+".0, "+t+".0);\n\n vec4 values = texture2D(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n "}}();n.FromPixelsProgram=r},{}],22:[function(e,t,n){"use strict";function r(e,t){var n=e.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return"int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],a=0;a0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)a="resRC",i="resRC";else{for(var o=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[],u=[],l=0;l= 1.0) {\n setOutput(getA("+a+"));\n } else {\n setOutput(getB("+a+"));\n }\n }\n "}}();n.WhereProgram=i},{"./shader_compiler":38}],27:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n,r,i){this.variableNames=["x"],this.outputShape=[];var a=t,o=e[3]-1;this.outputShape=e;var s,u="float("+n+") + float("+r+") * sum";s=.5===i?"inversesqrt("+u+")":1===i?"1.0/("+u+")":"exp(log("+u+") * float(-"+i+"));",this.userCode="\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -"+a+"; j <= "+a+"; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= "+o+") {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * "+s+";\n setOutput(val);\n }\n "}}();n.LRNProgram=r},{}],28:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,i=e.strideWidth,a=t-1-e.padInfo.top,o=n-1-e.padInfo.left,s=t*n-1;this.userCode="\n const ivec2 pads = ivec2("+a+", "+o+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < "+t+"; wR++) {\n float dyR = float(dyRCorner + wR) / "+r+".0;\n\n if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < "+n+"; wC++) {\n float dyC = float(dyCCorner + wC) / "+i+".0;\n\n if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = "+s+" - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * "+n+" + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n "}}();n.MaxPool2DBackpropProgram=r},{}],29:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1),this.variableNames=["matrixA","matrixB"];var i=n?e[1]:e[0],a=r?t[0]:t[1],o=n?e[0]:e[1];this.outputShape=[i,a];var s=function(e,t){return n?t+" + "+e+", aRow":"aRow, "+t+" + "+e},u=function(e,t){return r?"bCol, "+t+" + "+e:t+" + "+e+", bCol"},l=4*Math.floor(o/4),c=o%4;this.userCode=" float dotARowBCol(int aRow, int bCol) {\n float result = 0.0;\n for (int i = 0; i < "+l+"; i += 4) {\n vec4 a = vec4(\n getMatrixA("+s(0,"i")+"),\n getMatrixA("+s(1,"i")+"),\n getMatrixA("+s(2,"i")+"),\n getMatrixA("+s(3,"i")+")\n );\n vec4 b = vec4(\n getMatrixB("+u(0,"i")+"),\n getMatrixB("+u(1,"i")+"),\n getMatrixB("+u(2,"i")+"),\n getMatrixB("+u(3,"i")+")\n );\n\n result += dot(a, b);\n }\n\n if ("+(1===c)+") {\n result += getMatrixA("+s(0,l)+") *\n getMatrixB("+u(0,l)+");\n } else if ("+(2===c)+") {\n vec2 a = vec2(\n getMatrixA("+s(0,l)+"),\n getMatrixA("+s(1,l)+")\n );\n vec2 b = vec2(\n getMatrixB("+u(0,l)+"),\n getMatrixB("+u(1,l)+")\n );\n result += dot(a, b);\n } else if ("+(3===c)+") {\n vec3 a = vec3(\n getMatrixA("+s(0,l)+"),\n getMatrixA("+s(1,l)+"),\n getMatrixA("+s(2,l)+")\n );\n vec3 b = vec3(\n getMatrixB("+u(0,l)+"),\n getMatrixB("+u(1,l)+"),\n getMatrixB("+u(2,l)+")\n );\n result += dot(a, b);\n }\n\n return result;\n }\n\n void main() {\n ivec2 resRC = getOutputCoords();\n setOutput(dotARowBCol(resRC.x, resRC.y));\n }\n "}}();n.MatMulProgram=r},{}],30:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode="\n uniform float seed;\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < "+(t-1)+"; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float("+(t-1)+"));\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.seedLoc&&(t.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(t.seedLoc,e)}},e}();n.MultinomialProgram=r},{}],31:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float("+r+"), float("+n+"),\n float(index == coords.y)));\n }\n "}}();n.OneHotProgram=r},{}],32:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./shader_compiler"),i=function(){return function(e,t,n){this.variableNames=["x"],this.outputShape=t.map(function(t,n){return t[0]+e[n]+t[1]});var i=e.length,a=r.getCoordsDataType(i),o=t.map(function(e){return e[0]}).join(","),s=t.map(function(t,n){return t[0]+e[n]}).join(","),u=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i);this.userCode=1!==i?"\n "+a+" start = "+a+"("+o+");\n "+a+" end = "+a+"("+s+");\n\n void main() {\n "+a+" outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(float("+n+"));\n } else {\n "+a+" coords = outC - start;\n setOutput(getX("+u+"));\n }\n }\n ":"\n int start = "+o+";\n int end = "+s+";\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(float("+n+"));\n } else {\n setOutput(getX(outC - start));\n }\n }\n "}}();n.PadProgram=i},{"./shader_compiler":38}],33:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var r=e.filterHeight,i=e.filterWidth,a=e.strideHeight,o=e.strideWidth,s=e.padInfo.top,u=e.padInfo.left;this.outputShape=e.outShape;var l="avg"===t,c="0.0";if(l||(c="-1.0 / 0.0"),n)this.userCode="\n const ivec2 strides = ivec2("+a+", "+o+");\n const ivec2 pads = ivec2("+s+", "+u+");\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < "+r+"; wR++) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+i+"; wC++) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= "+e.inWidth+") {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = wR * "+i+" + wC;\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n ";else{var p=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(p="avgValue / count");var h=4*Math.floor(i/4),d=i%4,f="\n if ("+l+") {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n ";this.userCode="\n const ivec2 strides = ivec2("+a+", "+o+");\n const ivec2 pads = ivec2("+s+", "+u+");\n const float initializationValue = "+c+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= "+e.inWidth+") {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4("+c+");\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < "+r+"; wR++) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= "+e.inHeight+") {\n continue;\n }\n\n for (int wC = 0; wC < "+h+"; wC += 4) {\n int xC = xCCorner + wC;\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + 1, d),\n getValue(batch, xR, xC + 2, d),\n getValue(batch, xR, xC + 3, d)\n );\n\n "+f+"\n }\n\n int xC = xCCorner + "+h+";\n if ("+(1===d)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(2===d)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + 1, d),\n initializationValue,\n initializationValue\n );\n\n "+f+"\n } else if ("+(3===d)+") {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + 1, d),\n getValue(batch, xR, xC + 2, d),\n initializationValue\n );\n\n "+f+"\n }\n }\n setOutput("+p+");\n }\n "}}}();n.Pool2DProgram=r},{}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,i=e.inSize,a=Math.ceil(i/n);this.outputShape=[r,a];var o="sum"===t,s="0.0";o||(s="min"===t?"1.0 / 0.0":"-1.0 / 0.0");var u="min"===t?"min":"max",l=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===t&&(l="sumValue");var c=4*Math.floor(n/4),p=n%4,h="\n if ("+o+") {\n sumValue += dot(values, ones);\n } else {\n minMaxValue = "+u+"(values, minMaxValue);\n }\n ",d="";i%n>0&&(d="\n if (inIdx < 0 || inIdx >= "+i+") {\n return initializationValue;\n }\n "),this.userCode="\n const float initializationValue = "+s+";\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n "+d+"\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * "+n+";\n\n vec4 minMaxValue = vec4("+s+");\n float sumValue = 0.0;\n\n for (int i = 0; i < "+c+"; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n "+h+"\n }\n\n int inIdx = inOffset + "+c+";\n if ("+(1===p)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n "+h+"\n } else if ("+(2===p)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n "+h+"\n } else if ("+(3===p)+") {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n "+h+"\n }\n setOutput("+l+");\n }\n "}}();n.ReduceProgram=r},{}],35:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n,r){this.variableNames=["A"],this.outputShape=[];var i=e[0],a=e[1],o=e[2],s=e[3];this.outputShape=[i,t,n,s];var u=r?[a-1,o-1]:[a,o],l=r?[t-1,n-1]:[t,n];this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/l[0]+",\n "+u[1]/l[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+o+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n "}}();n.ResizeBilinearProgram=r},{}],36:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t,n,r){this.variableNames=["A"],this.outputShape=[];var i=e[0],a=e[1],o=e[2],s=e[3];this.outputShape=[i,t,n,s];var u=r?[a-1,o-1]:[a,o],l=r?[t-1,n-1]:[t,n];this.userCode="\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n "+u[0]/l[0]+",\n "+u[1]/l[1]+");\n const vec2 inputShapeRC = vec2("+a+".0, "+o+".0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + 0.5)));\n\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n "}}();n.ResizeNearestNeighborProgram=r},{}],37:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./shader_compiler"),i=function(){return function(e,t){this.variableNames=["x"];var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=e,1!==n){var i=function(n){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - coords["+n+"] - 1":"coords["+n+"]"},a=e.map(function(e,t){return i(t)}).join(","),o=r.getCoordsDataType(n);this.userCode="\n void main() {\n "+o+" coords = getOutputCoords();\n setOutput(getX("+a+"));\n }\n "}else this.userCode="\n void main() {\n int coord = getOutputCoords();\n setOutput(getX("+e[0]+" - coord - 1));\n }\n "}}();n.ReverseProgram=i},{"./shader_compiler":38}],38:[function(e,t,n){"use strict";function r(){return A.ENV.get("WEBGL_FLOAT_TEXTURE_ENABLED")?O:S}function i(){return A.ENV.get("WEBGL_FLOAT_TEXTURE_ENABLED")?k:C}function a(e){var t=e.shapeInfo.logicalShape;switch(t.length){case 0:return h(e);case 1:return d(e);case 2:return f(e);case 3:return g(e);case 4:return m(e);default:throw new Error(t.length+"-D input sampling is not yet supported")}}function o(e,t,n){var r=v(e);return r+=a(e),(n||E.arraysEqual(e.shapeInfo.logicalShape,t.logicalShape))&&(r+=b(e,t,n)),r}function s(e,t){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return u(e,t);case 2:return p(e,t);case 3:return l(e,t);case 4:return c(e,t);default:throw new Error(e.length+"-D output sampling is not yet supported")}}function u(e,t){return 1===t[0]?"\n int getOutputCoords() {\n return int(resultUV.x * "+t[1]+".0);\n }\n ":1===t[1]?"\n int getOutputCoords() {\n return int(resultUV.y * "+t[0]+".0);\n }\n ":"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n return resTexRC.x * "+t[1]+" + resTexRC.y;\n }\n "}function l(e,t){var n=e[1]*e[2],r=e[2];return"\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n int r = index / "+n+";\n index -= r * "+n+";\n int c = index / "+r+";\n int d = index - c * "+r+";\n return ivec3(r, c, d);\n }\n "}function c(e,t){var n=e[3],r=e[2]*n,i=e[1]*r;return"\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n int r = index / "+i+";\n index -= r * "+i+";\n\n int c = index / "+r+";\n index -= c * "+r+";\n\n int d = index / "+n+";\n int d2 = index - d * "+n+";\n\n return ivec4(r, c, d, d2);\n }\n "}function p(e,t){return E.arraysEqual(e,t)?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2("+t[0]+", "+t[1]+"));\n }\n ":1===e[1]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(index, 0);\n }\n ":1===e[0]?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n return ivec2(0, index);\n }\n ":"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+t[0]+", "+t[1]+"));\n int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n int r = index / "+e[1]+";\n int c = index - r * "+e[1]+";\n return ivec2(r, c);\n }\n "}function h(e){var t=e.name;return"\n float "+("get"+t.charAt(0).toUpperCase()+t.slice(1))+"() {\n return sampleTexture("+t+", halfCR);\n }\n "}function d(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);return"\n float "+n+"(int index) {\n return "+n+"Flat(index);\n }\n "}function f(e){var t=e.shapeInfo.logicalShape,n=e.shapeInfo.texShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[0],s=n[1];if(E.arraysEqual(t,n))return"\n float "+i+"(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2("+s+".0, "+o+".0);\n return sampleTexture("+r+", uv);\n }\n ";var u=E.squeezeShape(t),l=u.newShape,c=u.keptDims,p=l;if(p.length=1?"coords = 0;":u.map(function(e){return"coords["+(e+l)+"] = 0;"}).join("\n");var c="";return c=a<2&&i>0?"coords":e.shapeInfo.logicalShape.map(function(e,t){return"coords["+(t+l)+"]"}).join(", "),"\n float "+r+"() {\n "+o+" coords = getOutputCoords();\n "+s+"\n return get"+n+"("+c+");\n }\n "}function b(e,t,n){var r=e.shapeInfo.texShape,i=e.name,a=i.charAt(0).toUpperCase()+i.slice(1),o="get"+a+"AtOutCoords",s=_.getBroadcastDims(e.shapeInfo.logicalShape,t.logicalShape),u=e.shapeInfo.logicalShape.length,l=t.logicalShape.length,c=n&&(l>u||s.length>0),p=_.broadcastDimsAreOuter(s);if(c&&!p)return y(e,t,a,o);var h=t.texShape;if(E.arraysEqual(r,h))return"\n float "+o+"() {\n return sampleTexture("+i+", resultUV);\n }\n ";var d=E.sizeFromShape(r),f="";return c&&p&&(f="\n int mainPart = index / "+d+";\n index -= mainPart * "+d+";\n "),"\n float "+o+"() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2("+h[0]+", "+h[1]+"));\n int index = resTexRC.x * "+h[1]+" + resTexRC.y;\n "+f+"\n int texR = index / "+r[1]+";\n int texC = index - texR * "+r[1]+";\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2("+r[1]+".0, "+r[0]+".0);\n\n return sampleTexture("+i+", uv);\n }\n "}function w(e,t){var n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function x(e,t){return t.map(function(t){return e[t]}).join(", ")}Object.defineProperty(n,"__esModule",{value:!0});var A=e("../../environment"),E=e("../../util"),_=e("../../ops/broadcast_util"),T=e("./tex_util");n.makeShader=function(e,t,n,a){var u=r(),l=i(),c=e.map(function(e){return"uniform sampler2D "+e.name+";"}).join("\n"),p=e.map(function(e){return o(e,t,a)}).join("\n"),h=t.texShape,d=s(t.logicalShape,h);return[R,u,l,c,d,p,n].join("\n")};var S="\n uniform float NaN;\n\n const vec4 floatDeltas = vec4(\n 1.0,\n 1.0 / 255.0,\n 1.0 / (255.0 * 255.0),\n 1.0 / (255.0 * 255.0 * 255.0)\n );\n const float minValue = "+T.FLOAT_MIN+".0;\n const float maxValue = "+T.FLOAT_MAX+".0;\n const float range = (maxValue - minValue) / 255.0;\n const vec2 dotRange = vec2(1.0, range);\n\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n vec4 sampleValue = texture2D(textureSampler, uv);\n if (all(equal(sampleValue, vec4("+T.BYTE_NAN_VALUE+")))) {\n return NaN;\n }\n\n vec4 encValue = floor(sampleValue * 255.0 + 0.5);\n float decodedValue = dot(encValue, floatDeltas);\n return dot(vec2(minValue, decodedValue), dotRange);\n }\n",C="\n const vec4 floatPowers = vec4(\n 1.0,\n 255.0,\n 255.0 * 255.0,\n 255.0 * 255.0 * 255.0\n );\n const vec2 recipRange = vec2(1.0/range);\n const vec2 recipRange255 = vec2(1.0/(maxValue - minValue));\n\n void setOutput(float decodedValue) {\n if (isNaN(decodedValue)) {\n gl_FragColor = vec4("+T.BYTE_NAN_VALUE+");\n return;\n }\n\n float a = dot(vec2(decodedValue, -minValue), recipRange);\n float b = fract(a) * 255.0;\n float c = fract(b) * 255.0;\n float d = fract(c) * 255.0;\n gl_FragColor = floor(vec4(a, b, c, d)) / 255.0;\n\n // TODO(dsmilkov): Version above gets better accuracy but probably slower\n // than the version below. Benchmark to determine if the accuracy is worth\n // the cost.\n\n // float normValue = dot(vec2(decodedValue, -minValue), recipRange255);\n // vec4 f = normValue * floatPowers;\n // gl_FragColor = floor(fract(f) * 255.0) / 255.0;\n }\n",O="\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return texture2D(textureSampler, uv).r;\n }\n",k="\n void setOutput(float val) {\n gl_FragColor = vec4(val, 0, 0, 0);\n }\n",R="\n precision highp float;\n precision highp int;\n varying vec2 resultUV;\n const vec2 halfCR = vec2(0.5, 0.5);\n\n bool isNaN(float val) {\n float v1 = val * val;\n float v2 = val * val;\n return v1 == v2 ? false : true;\n }\n\n bool hasNaN(vec4 values) {\n vec4 v1 = values * values;\n vec4 v2 = values * values;\n return any(notEqual(v1, v2));\n }\n\n float getNaN(vec4 values) {\n return dot(vec4(1), values);\n }\n\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n const vec2 randomConst = vec2(\n 23.14069263277926, // e^pi (Gelfond's constant)\n 2.665144142690225 // 2^sqrt(2) (Gelfond–Schneider constant)\n );\n\n float random(float seed) {\n return fract(cos(dot(resultUV * seed, randomConst)) * 12345.6789);\n }\n\n \nvec2 UVfrom1D(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n\n \nvec2 UVfrom2D(int texNumR, int texNumC, int numC, int row, int col) {\n int index = row * numC + col;\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n\n \nvec2 UVfrom3D(int texNumR, int texNumC, int stride0,\n int stride1, int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * stride0 + col * stride1 + depth;\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n\n \nvec2 UVfrom4D(int texNumR, int texNumC, int stride0,\n int stride1, int stride2, int row, int col, int depth,\n int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * stride0 + col * stride1 + depth * stride2 + depth2;\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n\n";n.getCoordsDataType=function(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";throw Error("GPU for rank "+e+" is not yet supported")}},{"../../environment":5,"../../ops/broadcast_util":50,"../../util":95,"./tex_util":40}],39:[function(e,t,n){"use strict";function r(e){if(1===e)return"sourceLoc";if(2===e)return"sourceLoc.x, sourceLoc.y";if(3===e)return"sourceLoc.x, sourceLoc.y, sourceLoc.z";if(4===e)return"sourceLoc.x, sourceLoc.y, sourceLoc.z, sourceLoc.w";throw Error("Slicing for rank "+e+" is not yet supported")}Object.defineProperty(n,"__esModule",{value:!0});var i=e("./shader_compiler"),a=function(){function e(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;var t=i.getCoordsDataType(this.rank),n=r(this.rank);this.userCode="\n uniform "+t+" start;\n\n void main() {\n "+t+" sourceLoc = start + getOutputCoords();\n setOutput(getSource("+n+"));\n }\n "}return e.prototype.getCustomSetupFunc=function(e){var t=this;if(e.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+e.length+")");return function(n,r){if(null!=t.startLoc||(t.startLoc=n.getUniformLocationNoThrow(r,"start"),null!=t.startLoc))if(1===t.rank)n.gl.uniform1i(t.startLoc,e[0]);else if(2===t.rank)n.gl.uniform2i(t.startLoc,e[0],e[1]);else if(3===t.rank)n.gl.uniform3i(t.startLoc,e[0],e[1],e[2]);else{if(4!==t.rank)throw Error("Slicing for rank "+t.rank+" is not yet supported");n.gl.uniform4i(t.startLoc,e[0],e[1],e[2],e[3])}}},e}();n.SliceProgram=a},{"./shader_compiler":38}],40:[function(e,t,n){"use strict";function r(e,t){return e*t}function i(e,t){if(e%t!=0)throw new Error("unpackedSize ("+e+") must be a multiple of "+t);return e/t}function a(e,t){return[Math.ceil(t/2),Math.ceil(e/2)]}function o(e,t){var n=a(e,t);return n[0]*n[1]*4}Object.defineProperty(n,"__esModule",{value:!0});!function(e){e[e.FLOAT=0]="FLOAT",e[e.UNSIGNED_BYTE=1]="UNSIGNED_BYTE"}(n.TextureType||(n.TextureType={})),n.getUnpackedMatrixTextureShapeWidthHeight=function(e,t){return[t,e]},n.getUnpackedArraySizeFromMatrixSize=r,n.getColorMatrixTextureShapeWidthHeight=function(e,t){return[4*t,e]},n.getMatrixSizeFromUnpackedArraySize=i,n.encodeMatrixToUnpackedArray=function(e,t,n){var i=r(e.length,n);if(t.length= "+i);for(var a=0,o=0;o= "+r);for(var a=0,o=0;o= "+r);for(var i=0,a=0;a= "+i);for(var s=a(t,n),u=s[0],l=s[1],c=n%2==1,p=t%2==1,h=Math.floor(n/2),d=Math.floor(t/2),f=c?4:0,g=n,m=0,v=0;v= "+i);for(var o=n%2==1,s=t%2==1,u=Math.floor(n/2),l=Math.floor(t/2),c=a(t,n),p=c[0],h=c[1],d=o?4:0,f=n+(o?1:0),g=0,m=0,v=n,y=0;y0)return this.numFreeTextures--,this.numUsedTextures++,this.log(),this.freeTextures[n].shift();this.numUsedTextures++,this.log();var a=this.gpgpu.createMatrixTexture(e[0],e[1]);return this.allocatedTextures.push(a),a},e.prototype.releaseTexture=function(e,t,n){void 0===n&&(n=i.TextureType.FLOAT);var a=r(t,n);a in this.freeTextures||(this.freeTextures[a]=[]),this.freeTextures[a].push(e),this.numFreeTextures++,this.numUsedTextures--,this.usedTextureCount[a]--,this.log()},e.prototype.log=function(){if(this.logEnabled){var e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+e+")")}},e.prototype.getNumUsedTextures=function(){return this.numUsedTextures},e.prototype.getNumFreeTextures=function(){return this.numFreeTextures},e.prototype.dispose=function(){var e=this;null!=this.allocatedTextures&&(this.allocatedTextures.forEach(function(t){e.gpgpu.deleteMatrixTexture(t)}),this.freeTextures=null,this.allocatedTextures=null,this.usedTextureCount=null,this.numUsedTextures=0,this.numFreeTextures=0)},e}();n.TextureManager=a},{"./tex_util":40}],42:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t>4)throw Error("Tile for rank "+t+" is not yet supported");if(1===t)return"imod(resRC, "+e[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],i=0;i4)throw Error("Transpose for rank "+t+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=new Array(t),i=0;i= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n",n.STEP=function(e){return void 0===e&&(e=0),o+"\n return x > 0.0 ? 1.0 : float("+e+");\n "},n.NEG="return -x;",n.CEIL="return ceil(x);",n.FLOOR="return floor(x);",n.SIGN="return sign(x);",n.ROUND="\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n",n.EXP="return exp(x);",n.EXPM1="return exp(x) - 1.0;",n.LOG="return log(x);",n.LOG1P="return log(1.0 + x);",n.SQRT="return sqrt(x);",n.RSQRT="return inversesqrt(x);",n.SIGMOID="return 1.0 / (1.0 + exp(-1.0 * x));",n.SOFTPLUS="\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n",n.SIN="return sin(x);",n.COS="return cos(x);",n.TAN="return tan(x);",n.ASIN="return asin(x);",n.ACOS="return acos(x);",n.ATAN=o+"\n return atan(x);\n",n.SINH="\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n",n.COSH="\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n",n.TANH="\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n",n.ASINH="return log(x + sqrt(x * x + 1.0));",n.ACOSH="return log(x + sqrt(x * x - 1.0));",n.ATANH="return (log(1.0 + x) - log(1.0 - x)) / 2.0;",n.ERF='\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas, \n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = '+i.ERF_P+";\n float a1 = "+i.ERF_A1+";\n float a2 = "+i.ERF_A2+";\n float a3 = "+i.ERF_A3+";\n float a4 = "+i.ERF_A4+";\n float a5 = "+i.ERF_A5+";\n \n float t = 1.0 / (1.0 + p * x);\n return 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);\n",n.SQUARE="return x * x;",n.RECIPROCAL="return 1.0 / x;",n.LOGICAL_NOT="return float(!(x >= 1.0));",n.TO_INT="return float(int(x));"},{"../../ops/erf_util":56,"../../ops/selu_util":72}],45:[function(e,t,n){"use strict";function r(e,t){var n,r=g.ENV.get("WEBGL_VERSION");if(2===r?n=e.getContext("webgl2",t):1===r&&(n=e.getContext("webgl",t)||e.getContext("experimental-webgl",t)),0===r||null==n)throw new Error("This browser does not support WebGL.");return n}function i(e,t){var n=t();return a(e),n}function a(e){if(m){var t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+o(e,t))}}function o(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+t}}function s(e,t){var n=v.exec(t);if(null==n)return console.log("Couldn't parse line number in error: "+t),void console.log(e);for(var r=+n[1],i=e.split("\n"),a=i.length.toString().length+2,o=i.map(function(e,t){return f.rightPad((t+1).toString(),a)+e}),s=0,u=0;un){var i="[gl.TEXTURE0, gl.TEXTURE"+n+"]";throw new Error("textureUnit must be in "+i+".")}}Object.defineProperty(n,"__esModule",{value:!0});var d=null,f=e("../../util"),g=e("../../environment");n.createWebGLRenderingContext=function(e){var t=document.createElement("canvas");return t.width=1,t.height=1,r(t,e)},n.createWebGLRenderingContextFromCanvas=r,n.callAndCheck=i;var m=!1;n.enableDebugWebGLErrorChecking=function(e){m=e},n.checkWebGLError=a,n.getWebGLErrorMessage=o,n.getExtensionOrThrow=function(e,t){return p(e,function(){return e.getExtension(t)},'Extension "'+t+'" not supported on this browser.')},n.createVertexShader=function(e,t){var n=p(e,function(){return e.createShader(e.VERTEX_SHADER)},"Unable to create vertex WebGLShader.");if(i(e,function(){return e.shaderSource(n,t)}),i(e,function(){return e.compileShader(n)}),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n},n.createFragmentShader=function(e,t){var n=p(e,function(){return e.createShader(e.FRAGMENT_SHADER)},"Unable to create fragment WebGLShader.");if(i(e,function(){return e.shaderSource(n,t)}),i(e,function(){return e.compileShader(n)}),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw s(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n};var v=/ERROR: [0-9]+:([0-9]+):/g;n.createProgram=function(e){return p(e,function(){return e.createProgram()},"Unable to create WebGLProgram.")},n.linkProgram=function(e,t){if(i(e,function(){return e.linkProgram(t)}),!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")},n.validateProgram=function(e,t){if(i(e,function(){return e.validateProgram(t)}),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")},n.createStaticVertexBuffer=function(e,t){var n=p(e,function(){return e.createBuffer()},"Unable to create WebGLBuffer");return i(e,function(){return e.bindBuffer(e.ARRAY_BUFFER,n)}),i(e,function(){return e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)}),n},n.createStaticIndexBuffer=function(e,t){var n=p(e,function(){return e.createBuffer()},"Unable to create WebGLBuffer");return i(e,function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)}),i(e,function(){return e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)}),n},n.queryMaxTextureSize=u,n.getChannelsPerTexture=function(){return g.ENV.get("WEBGL_FLOAT_TEXTURE_ENABLED")&&2===g.ENV.get("WEBGL_VERSION")?1:4},n.createTexture=function(e){return p(e,function(){return e.createTexture()},"Unable to create WebGLTexture.")},n.validateTextureSize=function(e,t,n){var r=u(e);if(t<=0||n<=0)throw i="["+t+"x"+n+"]",new Error("Requested texture size "+i+" is invalid.");if(t>r||n>r){var i="["+t+"x"+n+"]",a="["+r+"x"+r+"]";throw new Error("Requested texture size "+i+" greater than WebGL maximum on this browser / GPU "+a+".")}},n.createFramebuffer=function(e){return p(e,function(){return e.createFramebuffer()},"Unable to create WebGLFramebuffer.")},n.bindVertexBufferToProgramAttribute=function(e,t,n,r,a,o,s){var u=e.getAttribLocation(t,n);return-1!==u&&(i(e,function(){return e.bindBuffer(e.ARRAY_BUFFER,r)}),i(e,function(){return e.vertexAttribPointer(u,a,e.FLOAT,!1,o,s)}),i(e,function(){return e.enableVertexAttribArray(u)}),!0)},n.bindTextureUnit=l,n.unbindTextureUnit=function(e,t){h(e,t),i(e,function(){return e.activeTexture(e.TEXTURE0+t)}),i(e,function(){return e.bindTexture(e.TEXTURE_2D,null)})},n.getProgramUniformLocationOrThrow=function(e,t,n){return p(e,function(){return e.getUniformLocation(t,n)},'uniform "'+n+'" not present in program.')},n.getProgramUniformLocation=function(e,t,n){return e.getUniformLocation(t,n)},n.bindTextureToProgramUniformSampler=function(e,t,n,r,a){i(e,function(){return l(e,n,a)}),i(e,function(){return e.uniform1i(r,a)})},n.bindCanvasToFramebuffer=function(e){i(e,function(){return e.bindFramebuffer(e.FRAMEBUFFER,null)}),i(e,function(){return e.viewport(0,0,e.canvas.width,e.canvas.height)}),i(e,function(){return e.scissor(0,0,e.canvas.width,e.canvas.height)})},n.bindColorTextureToFramebuffer=function(e,t,n){i(e,function(){return e.bindFramebuffer(e.FRAMEBUFFER,n)}),i(e,function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)})},n.unbindColorTextureFromFramebuffer=function(e,t){i(e,function(){return e.bindFramebuffer(e.FRAMEBUFFER,t)}),i(e,function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)})},n.validateFramebuffer=function(e){var t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+c(e,t))},n.getFramebufferErrorMessage=c,n.getTextureShapeFromLogicalShape=function(e,t){2!==t.length&&(t=f.squeezeShape(t).newShape);var n=u(e),r=f.sizeFromShape(t);return t.length<=1&&r<=n?[r,1]:2===t.length&&t[0]<=n&&t[1]<=n?t:3===t.length&&t[0]<=n&&t[1]*t[2]<=n?[t[0],t[1]*t[2]]:4===t.length&&t[0]<=n&&t[1]*t[2]*t[3]<=n?[t[0],t[1]*t[2]*t[3]]:f.sizeToSquarishShape(r)}},{"../../environment":5,"../../util":95}],46:[function(e,t,n){"use strict";function r(e,t){if(null==t||"float32"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error("Unknown data type $ {dtype}")}function i(e,t){for(var n=r(e,t),i=0;i=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}u((r=r.apply(e,t||[])).next())})},l=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(o=a[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(a,n[1])).done)return o;switch(a=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]2)throw new Error("Rank of probabilities must be 1 or 2, but is "+a);n=n||Math.random();var o=1===a?e.as2D(1,-1):e,s=p.ENV.engine.runKernel(function(e){return e.multinomial(o,r,t,n)},{logits2D:o});return 1===a?s.as1D():s},e.oneHot=function(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),f.assert("int32"===e.dtype,"Indices must be of dtype `int32`"),t<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+t);return p.ENV.engine.runKernel(function(i){return i.oneHot(e,t,n,r)},{indices:e})},e.fromPixels=function(e,t){if(void 0===t&&(t=3),t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");return p.ENV.engine.fromPixels(e,t)},e.toPixels=function(e,t){return u(this,void 0,void 0,function(){var n,r,i,a,o,s,u,c,p,h,d,g,m,v,y,b,w;return l(this,function(l){switch(l.label){case 0:if(f.assertArgumentsAreTensors({img:e},"toPixels"),2!==e.rank&&3!==e.rank)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+e.rank+".");if(n=e.shape.slice(0,2),r=n[0],i=n[1],(a=2===e.rank?1:e.shape[2])>4||2===a)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+a);return[4,e.min().data()];case 1:return o=l.sent()[0],[4,e.max().data()];case 2:if(s=l.sent()[0],"float32"===e.dtype){if(o<0||s>1)throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+o+" - "+s+"].")}else{if("int32"!==e.dtype)throw new Error("Unsupported type for toPixels: "+e.dtype+". Please use float32 or int32 tensors.");if(o<0||s>255)throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+o+" - "+s+"].")}return[4,e.data()];case 3:for(u=l.sent(),c="float32"===e.dtype?255:1,p=new Uint8ClampedArray(i*r*4),h=0;h=1,"Pass at least one tensor to tf.stack"),1===e.length)return e[0].expandDims(t);var n=e[0].rank,r=e[0].shape,i=e[0].dtype;f.assert(t<=n,"Axis must be <= rank of the tensor"),e.forEach(function(e){f.assertShapesMatch(r,e.shape,"All tensors passed to stack must have matching shapes")}),e.forEach(function(e){f.assert(i===e.dtype,"All tensors passed to stack must have matching dtypes")});var a=e.map(function(e){return e.expandDims(t)});return m.ConcatOps.concat(a,t)},e.split=function(e,t,n){void 0===n&&(n=0),f.assertArgumentsAreTensors({x:e},"split"),n=g.parseAxisParam(n,e.shape)[0];var r;"number"==typeof t?(f.assert(e.shape[n]%t==0,"Number of splits must evenly divide the axis."),r=Array(t).fill(e.shape[n]/t)):(f.assert(e.shape[n]===t.reduce(function(e,t){return e+t}),"The sum of sizes must match the size of the axis dimension."),r=t);var i=Array(e.rank).fill(0),a=e.shape.slice();return r.map(function(t){a[n]=t;var r=e.slice(i,a);return i[n]+=t,r})},e.expandDims=function(t,n){void 0===n&&(n=0),f.assertArgumentsAreTensors({x:t},"expandDims"),f.assert(n<=t.rank,"Axis must be <= rank of the tensor");var r=t.shape.slice();return r.splice(n,0,1),e.reshape(t,r)},e.linspace=function(t,n,i){if(0===i)throw new Error("Cannot request zero samples");var a=(n-t)/(i-1),o=r(i,"float32");o[0]=t;for(var s=1;s1;if(o||s||u)return e.zeros([0],a);var l=r(Math.abs(Math.ceil((n-t)/i)),a);n=-n&&e=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var a=e("../doc"),o=e("../environment"),s=e("../util"),u=e("./array_ops"),l=e("./broadcast_util"),c=e("./operation"),p=e("./ops"),h=function(){function e(){}return e.batchNormalization2d=function(t,n,r,i,a,o){return void 0===i&&(i=.001),s.assert(2===t.rank,"Error in batchNormalization3D: x must be rank 3 but got rank "+t.rank+"."),s.assert(2===n.rank||1===n.rank,"Error in batchNormalization2D: mean must be rank 2 or rank 1 but got rank "+n.rank+"."),s.assert(2===r.rank||1===r.rank,"Error in batchNormalization2D: variance must be rank 2 or rank 1 but got rank "+r.rank+"."),null!=a&&s.assert(2===a.rank||1===a.rank,"Error in batchNormalization2D: scale must be rank 2 or rank 1 but got rank "+a.rank+"."),null!=o&&s.assert(2===o.rank||1===o.rank,"Error in batchNormalization2D: offset must be rank 2 or rank 1 but got rank "+o.rank+"."),e.batchNormalization(t,n,r,i,a,o)},e.batchNormalization3d=function(t,n,r,i,a,o){return void 0===i&&(i=.001),s.assert(3===t.rank,"Error in batchNormalization3D: x must be rank 3 but got rank "+t.rank+"."),s.assert(3===n.rank||1===n.rank,"Error in batchNormalization3D: mean must be rank 3 or rank 1 but got rank "+n.rank+"."),s.assert(3===r.rank||1===r.rank,"Error in batchNormalization3D: variance must be rank 3 or rank 1 but got rank "+r.rank+"."),null!=a&&s.assert(3===a.rank||1===a.rank,"Error in batchNormalization3D: scale must be rank 3 or rank 1 but got rank "+a.rank+"."),null!=o&&s.assert(3===o.rank||1===o.rank,"Error in batchNormalization3D: offset must be rank 3 or rank 1 but got rank "+o.rank+"."),e.batchNormalization(t,n,r,i,a,o)},e.batchNormalization4d=function(t,n,r,i,a,o){return void 0===i&&(i=.001),s.assert(4===t.rank,"Error in batchNormalization4D: x must be rank 4 but got rank "+t.rank+"."),s.assert(4===n.rank||1===n.rank,"Error in batchNormalization4D: mean must be rank 4 or rank 1 but got rank "+n.rank+"."),s.assert(4===r.rank||1===r.rank,"Error in batchNormalization4D: variance must be rank 4 or rank 1 but got rank "+r.rank+"."),null!=a&&s.assert(4===a.rank||1===a.rank,"Error in batchNormalization4D: scale must be rank 4 or rank 1 but got rank "+a.rank+"."),null!=o&&s.assert(4===o.rank||1===o.rank,"Error in batchNormalization4D: offset must be rank 4 or rank 1 but got rank "+o.rank+"."),e.batchNormalization(t,n,r,i,a,o)},e.batchNormalization=function(e,t,n,i,a,c){void 0===i&&(i=.001),s.assertArgumentsAreTensors({x:e,mean:t,variance:n},"batchNormalization"),null!=a&&s.assertArgumentsAreTensors({scale:a},"batchNormalization"),null!=c&&s.assertArgumentsAreTensors({offset:c},"batchNormalization"),s.assert(t.rank===n.rank,"Batch normalization gradient requires mean and variance to have equal ranks."),s.assert(null==c||t.rank===c.rank,"Batch normalization gradient requires mean and offset to have equal ranks."),s.assert(null==a||t.rank===a.rank,"Batch normalization gradient requires mean and scale to have equal ranks.");var h;h=0===e.rank||1===e.rank?e.as4D(1,1,1,e.size):2===e.rank?e.as4D(1,1,e.shape[0],e.shape[1]):3===e.rank?e.as4D(1,e.shape[0],e.shape[1],e.shape[2]):e;return o.ENV.engine.runKernel(function(e){return e.batchNormalization(h,r(t),r(n),i,r(a),r(c))},{x:e,mean:t,variance:n,scale:a,offset:c},function(r){var o=null==a?u.ArrayOps.scalar(1):a,s=l.getReductionAxes(t.shape,h.shape),c=[];if(1===t.rank){for(var d=0;d=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../types"),s=e("../util"),u=e("./broadcast_util"),l=e("./operation"),c=e("./ops"),p=function(){function e(){}return e.add=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"add"),s.assertTypesMatch(e,t);var n=u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.add(e,t)},{a:e,b:t},function(r){return{a:function(){var t=r,i=u.getReductionAxes(e.shape,n);return i.length>0&&(t=t.sum(i)),t.reshape(e.shape)},b:function(){var e=r,i=u.getReductionAxes(t.shape,n);return i.length>0&&(e=e.sum(i)),e.reshape(t.shape)}}})},e.addStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in addStrict: "),e.add(t)},e.sub=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"sub"),s.assertTypesMatch(e,t);var n=u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.subtract(e,t)},{a:e,b:t},function(r){return{a:function(){var t=r,i=u.getReductionAxes(e.shape,n);return i.length>0&&(t=t.sum(i)),t.reshape(e.shape)},b:function(){var e=r,i=u.getReductionAxes(t.shape,n);return i.length>0&&(e=e.sum(i)),e.neg().reshape(t.shape)}}})},e.subStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in subStrict: "),e.sub(t)},e.pow=function(e,t){s.assertArgumentsAreTensors({base:e,exp:t},"pow");var n=u.assertAndGetBroadcastShape(e.shape,t.shape);e=e.cast(o.upcastType(e.dtype,t.dtype)),t=t.cast(o.upcastType(e.dtype,t.dtype));return a.ENV.engine.runKernel(function(n,r){return r(n.pow(e,t))},{base:e,exp:t},function(r,i){var a=i[0];return{base:function(){var i=r.mul(t.toFloat().mul(a.div(e))),o=u.getReductionAxes(e.shape,n);return o.length>0&&(i=i.sum(o)),i.reshape(e.shape)},exp:function(){var i=r.mul(a.mul(e.log()).toFloat()),o=u.getReductionAxes(t.shape,n);return o.length>0&&(i=i.sum(o)),i.reshape(t.shape)}}})},e.powStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in powStrict: "),e.pow(t)},e.mul=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"mul"),s.assertTypesMatch(e,t);var n=u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.multiply(e,t)},{a:e,b:t},function(r){return{a:function(){var i=r.mul(t.toFloat()),a=u.getReductionAxes(e.shape,n);return a.length>0?i.sum(a).reshape(e.shape):i},b:function(){var i=r.mul(e.toFloat()),a=u.getReductionAxes(t.shape,n);return a.length>0?i.sum(a).reshape(t.shape):i}}})},e.mulStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in multiplyStrict: "),e.mul(t)},e.div=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"div"),s.assertTypesMatch(e,t);var n=u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.divide(e,t)},{a:e,b:t},function(r){return{a:function(){var i=r.div(t.toFloat()),a=u.getReductionAxes(e.shape,n);return a.length>0?i.sum(a).reshape(e.shape):i},b:function(){var i=r.mul(e.toFloat()),a=u.getReductionAxes(t.shape,n);a.length>0&&(i=i.sum(a).reshape(t.shape));var o=t.square();return i.div(o.toFloat()).neg()}}})},e.divStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in divideStrict: "),e.div(t)},e.mod=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"mod"),s.assertTypesMatch(e,t);var n=u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.mod(e,t)},{a:e,b:t},function(r){return{a:function(){var t=u.getReductionAxes(e.shape,n);return t.length>0?r.sum(t).reshape(e.shape):r},b:function(){var i=r.mul(e.div(t).floor().neg()),a=u.getReductionAxes(t.shape,n);return a.length>0?i.sum(a).reshape(t.shape):i}}})},e.modStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in modStrict: "),e.mod(t)},e.minimum=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"minimum"),s.assertTypesMatch(e,t),"bool"===e.dtype&&(e=e.toInt()),"bool"===t.dtype&&(t=t.toInt()),u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.minimum(e,t)},{a:e,b:t},function(n){return{a:function(){return n.mul(e.lessEqual(t).toFloat())},b:function(){return n.mul(e.greater(t).toFloat())}}})},e.minimumStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in minimumStrict: "),e.minimum(t)},e.maximum=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"maximum"),s.assertTypesMatch(e,t),"bool"===e.dtype&&(e=e.toInt()),"bool"===t.dtype&&(t=t.toInt()),u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.maximum(e,t)},{a:e,b:t},function(n){return{a:function(){return n.mul(e.greaterEqual(t).toFloat())},b:function(){return n.mul(e.less(t).toFloat())}}})},e.maximumStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in minimumStrict: "),e.maximum(t)},e.squaredDifference=function(e,t){s.assertArgumentsAreTensors({a:e,b:t},"squaredDifference"),s.assertTypesMatch(e,t),u.assertAndGetBroadcastShape(e.shape,t.shape);return a.ENV.engine.runKernel(function(n){return n.squaredDifference(e,t)},{a:e,b:t},function(n){var r=c.scalar(2);return{a:function(){return n.mul(e.sub(t).mul(r))},b:function(){return n.mul(t.sub(e).mul(r))}}})},e.squaredDifferenceStrict=function(e,t){return s.assertShapesMatch(e.shape,t.shape,"Error in squaredDifferenceStrict: "),e.squaredDifference(t)},e.atan2=function(t,n){s.assertArgumentsAreTensors({a:t,b:n},"atan2"),s.assertTypesMatch(t,n);var r=u.assertAndGetBroadcastShape(t.shape,n.shape);return a.ENV.engine.runKernel(function(e){return e.atan2(t,n)},{a:t,b:n},function(i){return{a:function(){var a=e.add(c.square(t),c.square(n)),o=i.mul(n.div(a)),s=u.getReductionAxes(t.shape,r);return s.length>0&&(o=o.sum(s)),o.reshape(t.shape)},b:function(){var a=e.add(c.square(t),c.square(n)),o=c.neg(i.mul(t.div(a))),s=u.getReductionAxes(n.shape,r);return s.length>0&&(o=o.sum(s)),o.reshape(n.shape)}}})},r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"add",null),r([l.operation],e,"addStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"sub",null),r([l.operation],e,"subStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"pow",null),r([l.operation],e,"powStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"mul",null),r([l.operation],e,"mulStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"div",null),r([l.operation],e,"divStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"mod",null),r([l.operation],e,"modStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"minimum",null),r([l.operation],e,"minimumStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"maximum",null),r([l.operation],e,"maximumStrict",null),r([i.doc({heading:"Operations",subheading:"Arithmetic"}),l.operation],e,"squaredDifference",null),r([l.operation],e,"squaredDifferenceStrict",null),r([l.operation],e,"atan2",null),e}();n.BinaryOps=p},{"../doc":3,"../environment":5,"../types":94,"../util":95,"./broadcast_util":50,"./operation":65,"./ops":66}],50:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.getBroadcastDims=function(e,t){for(var n=e.length,r=[],i=0;i1&&1===o&&r.unshift(a)}return r},n.getReductionAxes=function(e,t){for(var n=[],r=0;r1)&&n.unshift(a)}return n},n.broadcastDimsAreOuter=function(e){for(var t=0;t1&&s>1&&o!==s)throw Error(r);n.unshift(Math.max(o,s))}return n}},{}],51:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./broadcast_util"),u=e("./operation"),l=function(){function e(){}return e.notEqual=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"notEqual"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.notEqual(e,t)},{a:e,b:t})},e.notEqualStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in notEqualStrict: "),e.notEqual(t)},e.less=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"less"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.less(e,t)},{a:e,b:t})},e.lessStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in lessStrict: "),e.less(t)},e.equal=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"equal"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.equal(e,t)},{a:e,b:t})},e.equalStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in equalStrict: "),e.equal(t)},e.lessEqual=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"lessEqual"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.lessEqual(e,t)},{a:e,b:t})},e.lessEqualStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in lessEqualStrict: "),e.lessEqual(t)},e.greater=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"greater"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.greater(e,t)},{a:e,b:t})},e.greaterStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in greaterStrict: "),e.greater(t)},e.greaterEqual=function(e,t){return o.assertArgumentsAreTensors({a:e,b:t},"greaterEqual"),o.assertTypesMatch(e,t),s.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.greaterEqual(e,t)},{a:e,b:t})},e.greaterEqualStrict=function(e,t){return o.assertShapesMatch(e.shape,t.shape,"Error in greaterEqualStrict: "),e.greaterEqual(t)},r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"notEqual",null),r([u.operation],e,"notEqualStrict",null),r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"less",null),r([u.operation],e,"lessStrict",null),r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"equal",null),r([u.operation],e,"equalStrict",null),r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"lessEqual",null),r([u.operation],e,"lessEqualStrict",null),r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"greater",null),r([u.operation],e,"greaterStrict",null),r([i.doc({heading:"Operations",subheading:"Logical"}),u.operation],e,"greaterEqual",null),r([u.operation],e,"greaterEqualStrict",null),e}();n.CompareOps=l},{"../doc":3,"../environment":5,"../util":95,"./broadcast_util":50,"./operation":65}],52:[function(e,t,n){"use strict";function r(e,t,n){l.assertParams(e.shape,t.shape,n);var r=l.computeOutShape(e.shape,t.shape,n),i=e.as2D(-1,s.sizeFromShape(e.shape.slice(n))),a=t.as2D(-1,s.sizeFromShape(t.shape.slice(n))),u=l.computeGradientSliceShapes(i.shape,a.shape),c=u.aBegin,p=u.aSize,h=u.bBegin,d=u.bSize;return o.ENV.engine.runKernel(function(e){return e.concat(i,a)},{a:i,b:a},function(e){return{a:function(){return e.slice(c,p)},b:function(){return e.slice(h,d)}}}).reshape(r)}var i=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var a=e("../doc"),o=e("../environment"),s=e("../util"),u=e("./axis_util"),l=e("./concat_util"),c=e("./operation"),p=function(){function e(){}return e.concat1d=function(t){return e.concat(t,0)},e.concat2d=function(t,n){return e.concat(t,n)},e.concat3d=function(t,n){return e.concat(t,n)},e.concat4d=function(t,n){return e.concat(t,n)},e.concat=function(e,t){void 0===t&&(t=0),s.assert(e.length>=1,"Pass at least one tensor to concat"),s.assertArgumentsAreTensors({tensors:e},"concat");var n=e[0];if(1===e.length)return n;for(var i=u.parseAxisParam(t,n.shape),a=1;a=0&&n=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var s=e("../doc"),u=e("../environment"),l=e("../util"),c=e("./conv_util"),p=e("./operation"),h=function(){function e(){}return e.conv1d=function(t,n,r,i,o,s,u){void 0===o&&(o="NWC"),void 0===s&&(s=1),l.assertArgumentsAreTensors({x:t,filter:n},"conv1d");var c=t,p=!1;2===t.rank&&(p=!0,c=t.as3D(1,t.shape[0],t.shape[1])),l.assert(3===c.rank,"Error in conv1d: input must be rank 3, but got rank "+c.rank+"."),l.assert(3===n.rank,"Error in conv1d: filter must be rank 3, but got rank "+n.rank+"."),null!=u&&l.assert(l.isInt(i),"Error in conv1d: pad must be an integer when using, dimRoundingMode "+u+" but got pad "+i+"."),l.assert(c.shape[2]===n.shape[1],"Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+n.shape[1]+"."),l.assert(a(r,s),"Error in conv1D: Either stride or dilation must be 1.Got stride "+r+" and dilation '"+s+"'"),l.assert("NWC"===o,"Error in conv1d: got dataFormat of "+o+" but only NWC is currently supported.");var h=n.as4D(1,n.shape[0],n.shape[1],n.shape[2]),d=c.as4D(c.shape[0],1,c.shape[1],c.shape[2]),f=[1,r],g=[1,s],m=e.conv2d(d,h,f,i,"NHWC",g,u);return p?m.as2D(m.shape[2],m.shape[3]):m.as3D(m.shape[0],m.shape[2],m.shape[3])},e.conv2d=function(t,n,r,o,s,p,h){void 0===s&&(s="NHWC"),void 0===p&&(p=[1,1]),l.assertArgumentsAreTensors({x:t,filter:n},"conv2d");var d=t,f=!1;3===t.rank&&(f=!0,d=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),l.assert(4===d.rank,"Error in conv2d: input must be rank 4, but got rank "+d.rank+"."),l.assert(4===n.rank,"Error in conv2d: filter must be rank 4, but got rank "+n.rank+"."),null!=h&&l.assert(l.isInt(o),"Error in conv2d: pad must be an integer when using, dimRoundingMode "+h+" but got pad "+o+"."),l.assert(d.shape[3]===n.shape[2],"Error in conv2d: depth of input ("+d.shape[3]+") must match input depth for filter "+n.shape[2]+"."),l.assert(a(r,p),"Error in conv2D: Either strides or dilations must be 1.Got strides "+r+" and dilations '"+p+"'"),l.assert("NHWC"===s,"Error in conv2d: got dataFormat of "+s+" but only NHWC is currently supported.");var g=c.computeConv2DInfo(d.shape,n.shape,r,p,o,h),m=u.ENV.engine.runKernel(function(e){return e.conv2d(d,n,g)},{x:d,filter:n},function(t){return l.assert(i(p),"Error in gradient of conv2D: dilation rates greater than 1 are notyet supported in gradients. Got dilations '"+p+"'"),{x:function(){return e.conv2dDerInput(d.shape,t,n,r,o)},filter:function(){return e.conv2dDerFilter(d,t,n.shape,r,o)}}});return f?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m},e.conv2dDerInput=function(e,t,n,r,i,a){l.assertArgumentsAreTensors({dy:t,filter:n},"conv2dDerInput"),l.assert(e.length===t.rank,"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match");var o=e,s=t,p=!1;3===t.rank&&(p=!0,s=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]),o=[1,e[0],e[1],e[2]]);var h=o[3],d=s.shape[3];l.assert(4===o.length,"Error in conv2dDerInput: inShape must be length 4, but got length "+o.length+"."),l.assert(4===s.rank,"Error in conv2dDerInput: dy must be rank 4, but got rank "+s.rank),l.assert(4===n.rank,"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank),l.assert(h===n.shape[2],"Error in conv2dDerInput: depth of input ("+h+") must match input depth for filter "+n.shape[2]+"."),l.assert(d===n.shape[3],"Error in conv2dDerInput: depth of output ("+d+") mustmatch output depth for filter "+n.shape[3]+"."),null!=a&&l.assert(l.isInt(i),"Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".");var f=c.computeConv2DInfo(o,n.shape,r,1,i,a),g=u.ENV.engine.runKernel(function(e){return e.conv2dDerInput(s,n,f)},{dy4D:s});return p?g.as3D(g.shape[1],g.shape[2],g.shape[3]):g},e.conv2dDerFilter=function(e,t,n,r,i,a){l.assertArgumentsAreTensors({x:e,dy:t},"conv2dDerFilter");var o=e;3===e.rank&&(o=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var s=t;3===s.rank&&(s=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),l.assert(4===o.rank,"Error in conv2dDerFilter: input must be rank 4, but got shape "+o.shape+"."),l.assert(4===s.rank,"Error in conv2dDerFilter: dy must be rank 4, but got shape "+s.shape+"."),l.assert(4===n.length,"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."),l.assert(o.shape[3]===n[2],"Error in conv2dDerFilter: depth of input "+o.shape[3]+") must match input depth in filter ("+n[2]+"."),l.assert(s.shape[3]===n[3],"Error in conv2dDerFilter: depth of dy ("+s.shape[3]+") must match output depth for filter ("+n[3]+")."),null!=a&&l.assert(l.isInt(i),"Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".");var p=c.computeConv2DInfo(o.shape,n,r,1,i,a);return u.ENV.engine.runKernel(function(e){return e.conv2dDerFilter(o,s,p)},{x4D:o,dy4D:s})},e.conv2dTranspose=function(t,n,r,i,a,o){return l.assertArgumentsAreTensors({x:t,filter:n},"conv2dTranspose"),e.conv2dDerInput(r,t,n,i,a,o)},e.depthwiseConv2d=function(e,t,n,r,i,o,s){void 0===i&&(i="NHWC"),void 0===o&&(o=[1,1]),l.assertArgumentsAreTensors({x:e,filter:t},"depthwiseConv2d");var p=e,h=!1;3===e.rank&&(h=!0,p=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),l.assert(4===p.rank,"Error in depthwiseConv2D: input must be rank 4, but got rank "+p.rank+"."),l.assert(4===t.rank,"Error in depthwiseConv2D: filter must be rank 4, but got rank "+t.rank+"."),l.assert(p.shape[3]===t.shape[2],"Error in depthwiseConv2D: number of input channels ("+p.shape[3]+") must match the inChannels dimension in filter "+t.shape[2]+"."),null==o&&(o=[1,1]),l.assert(a(n,o),"Error in depthwiseConv2d: Either strides or dilations must be 1.Got strides "+n+" and dilations '"+o+"'"),null!=s&&l.assert(l.isInt(r),"Error in depthwiseConv2D: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+r+".");var d=c.computeConv2DInfo(p.shape,t.shape,n,o,r,s,!0),f=u.ENV.engine.runKernel(function(e){return e.depthwiseConv2D(p,t,d)},{x4D:p,filter:t});return h?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f},e.separableConv2d=function(t,n,r,i,a,o,s){void 0===o&&(o=[1,1]),void 0===s&&(s="NHWC"),l.assertArgumentsAreTensors({x:t,depthwiseFilter:n,pointwiseFilter:r},"separableConv2d");var u=t,c=!1;if(3===t.rank&&(c=!0,u=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");l.assert(4===u.rank,"Error in separableConv2d: input must be rank 4, but got rank "+u.rank+"."),l.assert(4===n.rank,"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+n.rank+"."),l.assert(4===r.rank,"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+n.rank+"."),l.assert(1===r.shape[0],"Error in separableConv2d: the first dimension of pointwise filter must be 1, but got "+r.shape[0]+"."),l.assert(1===r.shape[1],"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+r.shape[1]+".");var p=n.shape[2],h=n.shape[3];l.assert(r.shape[2]===p*h,"Error in separableConv2d: the third dimension of pointwise filter must be "+p*h+", but got "+r.shape[2]+".");var d=e.depthwiseConv2d(u,n,i,a,s,o),f=e.conv2d(d,r,1,"valid",s);return c?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f},o([s.doc({heading:"Operations",subheading:"Convolution"}),p.operation],e,"conv1d",null),o([s.doc({heading:"Operations",subheading:"Convolution"}),p.operation],e,"conv2d",null),o([p.operation],e,"conv2dDerInput",null),o([p.operation],e,"conv2dDerFilter",null),o([s.doc({heading:"Operations",subheading:"Convolution"}),p.operation],e,"conv2dTranspose",null),o([s.doc({heading:"Operations",subheading:"Convolution"}),p.operation],e,"depthwiseConv2d",null),o([s.doc({heading:"Operations",subheading:"Convolution"}),p.operation],e,"separableConv2d",null),e}();n.ConvOps=h},{"../doc":3,"../environment":5,"../util":95,"./conv_util":55,"./operation":65}],55:[function(e,t,n){"use strict";function r(e,t,n,r,i,a,l,c){void 0===l&&(l=!1),void 0===c&&(c="channelsLast");var p=[-1,-1,-1,-1],h=p[0],d=p[1],f=p[2],g=p[3];if("channelsLast"===c)h=e[0],d=e[1],f=e[2],g=e[3];else{if("channelsFirst"!==c)throw new Error("Unknown dataFormat "+c);h=e[0],g=e[1],d=e[2],f=e[3]}var m,v=t[0],y=t[1],b=t[3],w=o(n),x=w[0],A=w[1],E=o(r),_=E[0],T=E[1],S=u(i,d,f,x,A,s(v,_),s(y,T),a),C=S.padInfo,O=S.outHeight,k=S.outWidth,R=l?b*g:b;return"channelsFirst"===c?m=[h,R,O,k]:"channelsLast"===c&&(m=[h,O,k,R]),{batchSize:h,dataFormat:c,inHeight:d,inWidth:f,inChannels:g,outHeight:O,outWidth:k,outChannels:R,padInfo:C,strideHeight:x,strideWidth:A,filterHeight:v,filterWidth:y,dilationHeight:_,dilationWidth:T,inShape:e,outShape:m,filterShape:t}}function i(e,t,n,r,i,o){null==i&&(i=a(e,t,r));var s=e[0],u=e[1],p=l((s-t+2*i)/r+1,o);c.assert(c.isInt(p),"The output # of rows ("+p+") must be an integer. Change the stride and/or zero pad parameters");var h=l((u-t+2*i)/r+1,o);return c.assert(c.isInt(h),"The output # of columns ("+h+") must be an integer. Change the stride and/or zero pad parameters"),[p,h,n]}function a(e,t,n,r){void 0===r&&(r=1);var i=s(t,r);return Math.floor((e[0]*(n-1)-n+i)/2)}function o(e){return"number"==typeof e?[e,e]:e}function s(e,t){return t<=1?e:e+(e-1)*(t-1)}function u(e,t,n,r,a,o,s,u){var l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};var h=i([t,n,1],o,1,r,e,u);c=h[0],p=h[1]}else if("same"===e){var d=((c=Math.ceil(t/r))-1)*r+o-t,f=((p=Math.ceil(n/a))-1)*a+s-n,g=Math.floor(d/2),m=d-g,v=Math.floor(f/2);l={top:g,bottom:m,left:v,right:f-v,type:"SAME"}}else{if("valid"!==e)throw Error("Unknown padding parameter: "+e);l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-o+1)/r),p=Math.ceil((n-s+1)/a)}return{padInfo:l,outHeight:c,outWidth:p}}function l(e,t){if(!t)return e;switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error("Unknown roundingMode "+t)}}Object.defineProperty(n,"__esModule",{value:!0});var c=e("../util");n.computePool2DInfo=function(e,t,n,i,a,s){void 0===s&&(s="channelsLast");var u,l=o(t),c=l[0],p=l[1];if("channelsLast"===s)u=[c,p,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);u=[c,p,e[1],e[1]]}return r(e,u,n,1,i,a,!1,s)},n.computeConv2DInfo=r,n.computeDefaultPad=a},{"../util":95}],56:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ERF_P=.3275911,n.ERF_A1=.254829592,n.ERF_A2=-.284496736,n.ERF_A3=1.421413741,n.ERF_A4=-1.453152027,n.ERF_A5=1.061405429},{}],57:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./operation"),u=function(){function e(){}return e.resizeBilinear=function(e,t,n){void 0===n&&(n=!1),o.assertArgumentsAreTensors({images:e},"resizeBilinear"),o.assert(3===e.rank||4===e.rank,"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+e.rank+"."),o.assert(2===t.length,"Error in resizeBilinear: new shape must 2D, but got shape "+t+".");var r=e,i=!1;3===e.rank&&(i=!0,r=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var s=t[0],u=t[1],l=a.ENV.engine.runKernel(function(e){return e.resizeBilinear(r,s,u,n)},{batchImages:r});return i?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l},e.resizeNearestNeighbor=function(e,t,n){void 0===n&&(n=!1),o.assertArgumentsAreTensors({images:e},"resizeNearestNeighbor"),o.assert(3===e.rank||4===e.rank,"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+e.rank+"."),o.assert(2===t.length,"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+t+"."),o.assert("float32"===e.dtype||"int32"===e.dtype,"`images` must have `int32` or `float32` as dtype");var r=e,i=!1;3===e.rank&&(i=!0,r=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var s=t[0],u=t[1],l=a.ENV.engine.runKernel(function(e){return e.resizeNearestNeighbor(r,s,u,n)},{batchImages:r});return i?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l},r([i.doc({heading:"Operations",subheading:"Images",namespace:"image"}),s.operation],e,"resizeBilinear",null),r([i.doc({heading:"Operations",subheading:"Images",namespace:"image"}),s.operation],e,"resizeNearestNeighbor",null),e}();n.ImageOps=u},{"../doc":3,"../environment":5,"../util":95,"./operation":65}],58:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../types"),s=e("../util"),u=e("./broadcast_util"),l=e("./operation"),c=function(){function e(){}return e.logicalNot=function(e){return s.assertArgumentsAreTensors({x:e},"logicalNot"),s.assert("bool"===e.dtype,"Error Array must be of type bool."),a.ENV.engine.runKernel(function(t){return t.logicalNot(e)},{x:e})},e.logicalAnd=function(e,t){return s.assertArgumentsAreTensors({a:e,b:t},"logicalAnd"),s.assert("bool"===e.dtype&&"bool"===t.dtype,"Error Array must be of type bool."),u.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.logicalAnd(e,t)},{a:e,b:t})},e.logicalOr=function(e,t){return s.assertArgumentsAreTensors({a:e,b:t},"logicalOr"),s.assert("bool"===e.dtype&&"bool"===t.dtype,"Error Array must be of type bool."),u.assertAndGetBroadcastShape(e.shape,t.shape),a.ENV.engine.runKernel(function(n){return n.logicalOr(e,t)},{a:e,b:t})},e.logicalXor=function(t,n){return s.assertArgumentsAreTensors({a:t,b:n},"logicalXor"),s.assert("bool"===t.dtype&&"bool"===n.dtype,"Error Array must be of type bool."),u.assertAndGetBroadcastShape(t.shape,n.shape),e.logicalOr(t,n).logicalAnd(e.logicalAnd(t,n).logicalNot())},e.where=function(e,t,n){s.assertArgumentsAreTensors({condition:e,a:t,b:n},"where"),s.assert("bool"===e.dtype||"bool"===t.dtype||"bool"===n.dtype,"Error Array must be of type bool."),s.assertShapesMatch(t.shape,n.shape,"Error in where: "),1===e.rank?s.assert(e.shape[0]===t.shape[0],"The first dimension of `a` must match the size of `condition`."):s.assertShapesMatch(e.shape,n.shape,"Error in where: ");var r=o.upcastType(t.dtype,n.dtype);return a.ENV.engine.runKernel(function(i){return i.where(e,t,n,r)},{condition:e,a:t,b:n})},r([i.doc({heading:"Operations",subheading:"Logical"}),l.operation],e,"logicalNot",null),r([i.doc({heading:"Operations",subheading:"Logical"}),l.operation],e,"logicalAnd",null),r([i.doc({heading:"Operations",subheading:"Logical"}),l.operation],e,"logicalOr",null),r([i.doc({heading:"Operations",subheading:"Logical"}),l.operation],e,"logicalXor",null),r([i.doc({heading:"Operations",subheading:"Logical"}),l.operation],e,"where",null),e}();n.LogicalOps=c},{"../doc":3,"../environment":5,"../types":94,"../util":95,"./broadcast_util":50,"./operation":65}],59:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i,a=e("../doc"),o=e("../util"),s=e("./operation"),u=e("./ops");!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(i=n.Reduction||(n.Reduction={}));var l=function(){function e(){}return e.computeWeightedLoss=function(e,t,n){void 0===n&&(n=i.SUM_BY_NONZERO_WEIGHTS),o.assertArgumentsAreTensors({losses:e},"computeWeightedLoss"),null!=t&&o.assertArgumentsAreTensors({weights:t},"computeWeightedLoss");var r=null==t?e:e.mul(t);if(n===i.NONE)return r;if(n===i.SUM)return r.sum();if(n===i.MEAN)return null==t?r.mean():r.sum().div(t.sum());if(n===i.SUM_BY_NONZERO_WEIGHTS){if(null==t)return r.sum().div(u.scalar(e.size));var a=t.notEqual(u.scalar(0)).sum().toFloat();return r.sum().div(a)}throw Error("Unknown reduction: "+n)},e.absoluteDifference=function(t,n,r,a){void 0===a&&(a=i.SUM_BY_NONZERO_WEIGHTS),o.assertArgumentsAreTensors({labels:t,predictions:n},"absoluteDifference"),null!=r&&o.assertArgumentsAreTensors({weights:r},"absoluteDifference"),o.assertShapesMatch(t.shape,n.shape,"Error in absoluteDifference: ");var s=t.sub(n).abs();return e.computeWeightedLoss(s,r,a)},r([a.doc({heading:"Training",subheading:"Losses",namespace:"losses"}),s.operation],e,"computeWeightedLoss",null),r([a.doc({heading:"Training",subheading:"Losses",namespace:"losses"}),s.operation],e,"absoluteDifference",null),e}();n.LossOps=l},{"../doc":3,"../util":95,"./operation":65,"./ops":66}],60:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./operation"),u=function(){function e(){}return e.localResponseNormalization=function(e,t,n,r,i){void 0===t&&(t=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=.5),o.assertArgumentsAreTensors({x:e},"localResponseNormalization"),o.assert(4===e.rank||3===e.rank,"Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank "+e.rank+"."),o.assert(o.isInt(t),"Error in localResponseNormalization3D: radius must be an integer\n but got radius "+t+".");var s=e,u=!1;3===e.rank&&(u=!0,s=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var l=a.ENV.engine.runKernel(function(e){return e.localResponseNormalization4D(s,t,n,r,i)},{x4D:s});return u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l},r([i.doc({heading:"Operations",subheading:"Normalization"}),s.operation],e,"localResponseNormalization",null),e}();n.LRNOps=u},{"../doc":3,"../environment":5,"../util":95,"./operation":65}],61:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../util"),o=e("./operation"),s=function(){function e(){}return e.multiRNNCell=function(e,t,n,r){a.assertArgumentsAreTensors({data:t,c:n,h:r},"multiRNNCell");for(var i=t,o=[],s=0;s=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./operation"),u=function(){function e(){}return e.matMul=function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1),o.assertArgumentsAreTensors({a:e,b:t},"matMul");var i=n?e.shape[0]:e.shape[1],s=r?t.shape[1]:t.shape[0];o.assert(2===e.rank&&2===t.rank,"Error in matMul: inputs must be rank 2, got ranks "+e.rank+" and "+t.rank+"."),o.assert(i===s,"Error in matMul: inner shapes ("+i+") and ("+s+") of Tensors with shapes "+e.shape+" and "+t.shape+" and transposeA="+n+" and transposeB="+r+" must match.");return a.ENV.engine.runKernel(function(i){return i.matMul(e,t,n,r)},{a:e,b:t},function(i){return n||r?!n&&r?{a:function(){return i.matMul(t.toFloat(),!1,!1)},b:function(){return i.matMul(e.toFloat(),!0,!1)}}:n&&!r?{a:function(){return t.toFloat().matMul(i,!1,!0)},b:function(){return e.toFloat().matMul(i,!1,!1)}}:{a:function(){return t.toFloat().matMul(i,!0,!0)},b:function(){return i.matMul(e.toFloat(),!0,!0)}}:{a:function(){return i.matMul(t.toFloat(),!1,!0)},b:function(){return e.toFloat().matMul(i,!0,!1)}}})},e.vectorTimesMatrix=function(e,t){return o.assert(1===e.rank,"Error in vectorTimesMatrix: first input must be rank 1, but got rank "+e.rank+"."),o.assert(2===t.rank,"Error in vectorTimesMatrix: second input must be rank 2, but got rank "+t.rank+"."),o.assert(e.size===t.shape[0],"Error in vectorTimesMatrix: size of vector ("+e.size+") must match first dimension of matrix ("+t.shape[0]+")"),e.as2D(1,-1).matMul(t).as1D()},e.matrixTimesVector=function(e,t){return o.assert(1===t.rank,"Error in matrixTimesVector: second input must rank 1, but got rank "+t.rank+"."),o.assert(2===e.rank,"Error in matrixTimesVector: first input must be a rank 2, but got rank "+e.rank+"."),o.assert(t.size===e.shape[1],"Error in matrixTimesVector: size of first rank 1 input "+t.size+" must match inner dimension of second rank 2 input, but got shape "+e.shape+"."),e.matMul(t.as2D(-1,1)).as1D()},e.dotProduct=function(e,t){return o.assert(1===e.rank&&1===t.rank,"Error in dotProduct: inputs must be rank 1, but got ranks "+e.rank+" and "+t.rank+"."),o.assert(e.size===t.size,"Error in dotProduct: size of inputs ("+e.size+") and ("+t.size+") must match."),e.as2D(1,-1).matMul(t.as2D(-1,1)).asScalar()},e.outerProduct=function(e,t){return o.assert(1===e.rank&&1===t.rank,"Error in outerProduct: inputs must be rank 1, but got ranks "+e.rank+" and "+t.rank+"."),e.as2D(-1,1).matMul(t.as2D(1,-1))},r([i.doc({heading:"Operations",subheading:"Matrices"}),s.operation],e,"matMul",null),r([s.operation],e,"vectorTimesMatrix",null),r([s.operation],e,"matrixTimesVector",null),r([s.operation],e,"dotProduct",null),r([i.doc({heading:"Operations",subheading:"Matrices"}),s.operation],e,"outerProduct",null),e}();n.MatmulOps=u},{"../doc":3,"../environment":5,"../util":95,"./operation":65}],63:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../util"),o=e("./array_ops"),s=e("./binary_ops"),u=e("./operation"),l=function(){function e(){}return e.movingAverage=function(e,t,n,r,i){void 0===i&&(i=!0),a.assertArgumentsAreTensors({v:e,x:t},"movingAverage"),a.assertTypesMatch(e,t),a.assert(a.arraysEqual(e.shape,t.shape),"Shape mismatch in v and x");var u=o.ArrayOps.scalar(1);n="number"==typeof n?o.ArrayOps.scalar(n):n;var l=u.sub(n),c=t.sub(e).mul(l);return i&&(a.assert(null!=r,"When using zeroDebias: true, step is required."),r="number"==typeof r?o.ArrayOps.scalar(r):r,c=c.div(u.sub(s.BinaryOps.pow(n,r)))),e.add(c)},r([i.doc({heading:"Operations",subheading:"Moving Average"}),u.operation],e,"movingAverage",null),e}();n.MovingAverageOps=l},{"../doc":3,"../util":95,"./array_ops":46,"./binary_ops":49,"./operation":65}],64:[function(e,t,n){"use strict";function r(e,t,n){if(void 0===n&&(n=null),0===e.rank)return e.abs();if(1!==e.rank&&null===n)return r(e.reshape([-1]),t,n);if(1===e.rank||"number"==typeof n||n instanceof Array&&1===n.length){if(1===t)return e.abs().sum(n);if(t===1/0)return e.abs().max(n);if(t===-1/0)return e.abs().min(n);if("euclidean"===t||2===t)return e.abs().pow(l.scalar(2,"int32")).sum(n).sqrt();throw new Error("Error in norm: invalid ord value: "+t)}if(n instanceof Array&&2===n.length){if(1===t)return e.abs().sum(n[0]).max(n[1]-1);if(t===1/0)return e.abs().sum(n[1]).max(n[0]);if(t===-1/0)return e.abs().sum(n[1]).min(n[0]);if("fro"===t||"euclidean"===t)return e.square().sum(n).sqrt();throw new Error("Error in norm: invalid ord value: "+t)}throw new Error("Error in norm: invalid axis: "+n)}var i=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var a=e("../doc"),o=e("../util"),s=e("./axis_util"),u=e("./operation"),l=e("./ops"),c=function(){function e(){}return e.norm=function(e,t,n,i){void 0===t&&(t="euclidean"),void 0===n&&(n=null),void 0===i&&(i=!1),o.assertArgumentsAreTensors({x:e},"norm");var a=r(e,t,n),u=a.shape;if(i){var l=s.parseAxisParam(n,e.shape);u=s.expandShapeToKeepDim(a.shape,l)}return a.reshape(u)},i([a.doc({heading:"Operations",subheading:"Matrices"}),u.operation],e,"norm",null),e}();n.NormOps=c},{"../doc":3,"../util":95,"./axis_util":47,"./operation":65,"./ops":66}],65:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("../globals");n.operation=function(e,t,n){var i=n.value;return n.value=function(){for(var e=[],n=0;n=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./conv_util"),u=e("./operation"),l=function(){function e(){}return e.maxPool=function(t,n,r,i,u){o.assertArgumentsAreTensors({x:t},"maxPool");var l=t,c=!1;3===t.rank&&(c=!0,l=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),o.assert(4===l.rank,"Error in maxPool: input must be rank 4 but got rank "+l.rank+"."),null!=u&&o.assert(o.isInt(i),"Error in maxPool: pad must be an integer when using, dimRoundingMode "+u+" but got pad "+i+".");var p=s.computePool2DInfo(l.shape,n,r,i,u),h=a.ENV.engine.runKernel(function(e,t){return t(e.maxPool(l,p))},{x:l},function(t,a){var o=a[0];return{x:function(){return e.maxPoolBackprop(t,l,o,n,r,i)}}});return c?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h},e.maxPoolBackprop=function(e,t,n,r,i,u,l){o.assertArgumentsAreTensors({dy:e,input:t,output:n},"maxPoolBackprop"),o.assert(t.rank===e.rank,"Rank of input ("+t.rank+") does not match rank of dy ("+e.rank+")"),o.assert(4===e.rank,"Error in maxPoolBackprop: dy must be rank 4 but got rank "+e.rank+"."),o.assert(4===t.rank,"Error in maxPoolBackprop: input must be rank 4 but got rank "+t.rank+"."),null!=l&&o.assert(o.isInt(u),"Error in maxPoolBackprop: pad must be an integer when using, dimRoundingMode "+l+" but got pad "+u+".");var c=s.computePool2DInfo(t.shape,r,i,u,l);return a.ENV.engine.runKernel(function(r){return r.maxPoolBackprop(e,t,n,c)},{dy:e,input:t})},e.avgPool=function(t,n,r,i,u){o.assertArgumentsAreTensors({x:t},"avgPool"),o.assert("float32"===t.dtype,"The input dtype to avgPool must be float32");var l=t,c=!1;3===t.rank&&(c=!0,l=t.as4D(1,t.shape[0],t.shape[1],t.shape[2])),o.assert(4===l.rank,"Error in avgPool: x must be rank 4 but got rank "+l.rank+"."),null!=u&&o.assert(o.isInt(i),"Error in avgPool: pad must be an integer when using, dimRoundingMode "+u+" but got pad "+i+".");var p=s.computePool2DInfo(l.shape,n,r,i),h=a.ENV.engine.runKernel(function(e){return e.avgPool(l,p)},{x:l},function(t){return{x:function(){return e.avgPoolBackprop(t,l,n,r,i)}}});return h=h.cast(t.dtype),c?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h},e.avgPoolBackprop=function(e,t,n,r,i){o.assertArgumentsAreTensors({dy:e,input:t},"avgPoolBackprop"),o.assert(t.rank===e.rank,"Rank of input ("+t.rank+") does not match rank of dy ("+e.rank+")");var u=t,l=e,c=!1;3===t.rank&&(c=!0,u=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]),l=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),o.assert(4===l.rank,"Error in avgPoolBackprop: dy must be rank 4 but got rank "+l.rank+"."),o.assert(4===u.rank,"Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+".");var p=s.computePool2DInfo(u.shape,n,r,i),h=a.ENV.engine.runKernel(function(e){return e.avgPoolBackprop(l,u,p)},{dy4D:l,input4D:u});return c?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h},r([i.doc({heading:"Operations",subheading:"Convolution"}),u.operation],e,"maxPool",null),r([u.operation],e,"maxPoolBackprop",null),r([i.doc({heading:"Operations",subheading:"Convolution"}),u.operation],e,"avgPool",null),r([u.operation],e,"avgPoolBackprop",null),e}();n.PoolOps=l},{"../doc":3,"../environment":5,"../util":95,"./conv_util":55,"./operation":65}],68:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("seedrandom"),i=function(){function e(e,t,n,i,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=i,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var o=a||Math.random();this.random=r.alea(o.toString())}return e.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var e=this.nextVal;return this.nextVal=NaN,e}for(var t,n,r=!1;!r;){var i=void 0,a=void 0,o=void 0;do{o=(i=2*this.random()-1)*i+(a=2*this.random()-1)*a}while(o>=1||0===o);var s=Math.sqrt(-2*Math.log(o)/o);t=this.mean+this.stdDev*i*s,n=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(t)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(t)},e.prototype.convertValue=function(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)},e.prototype.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},e}();n.MPRandGauss=i},{seedrandom:135}],69:[function(e,t,n){"use strict";function r(e,t){for(var n=t;n=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../globals"),s=e("../util"),u=e("./axis_util"),l=e("./operation"),c=e("./ops"),p=function(){function e(){}return e.logSumExp=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"logSumExp");var r=u.parseAxisParam(t,e.shape),i=e.max(r,!0),a=e.sub(i).exp().sum(r).log(),o=i.reshape(a.shape).add(a);if(n){var l=u.expandShapeToKeepDim(o.shape,r);return o.reshape(l)}return o},e.sum=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"sum"),"bool"===e.dtype&&(e=e.toInt());var r=u.parseAxisParam(t,e.shape);return o.customGrad(function(e){var t=u.getAxesPermutation(r,e.rank),i=r,o=e;null!=t&&(o=e.transpose(t),i=u.getInnerMostAxes(i.length,e.rank));var s=a.ENV.engine.runKernel(function(e){return e.sum(o,i)},{permutedX:o});if(n){var l=u.expandShapeToKeepDim(s.shape,r);s=s.reshape(l)}return{value:s,gradFunc:function(t){var n=e.shape.slice();return r.forEach(function(e){n[e]=1}),t.reshape(n).mul(c.ones(e.shape,"float32"))}}})(e)},e.mean=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"mean");var r=u.parseAxisParam(t,e.shape),i=u.computeOutAndReduceShapes(e.shape,r)[1],a=s.sizeFromShape(i);return o.customGrad(function(e){var i=c.scalar(a);return{value:(i.dtype===e.dtype?e:e.cast(i.dtype)).div(i).sum(t,n),gradFunc:function(t){var n=e.shape.slice();return r.forEach(function(e){n[e]=1}),t.reshape(n).mul(c.ones(e.shape,"float32")).div(i)}}})(e)},e.min=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"min");var r=u.parseAxisParam(t,e.shape),i=r,o=u.getAxesPermutation(i,e.rank);null!=o&&(e=e.transpose(o),i=u.getInnerMostAxes(i.length,e.rank));var l=a.ENV.engine.runKernel(function(t){return t.min(e,i)},{x:e});if(n){var c=u.expandShapeToKeepDim(l.shape,r);return l.reshape(c)}return l},e.max=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"max");var r=u.parseAxisParam(t,e.shape),i=r,o=u.getAxesPermutation(i,e.rank);null!=o&&(e=e.transpose(o),i=u.getInnerMostAxes(i.length,e.rank));var l=a.ENV.engine.runKernel(function(t){return t.max(e,i)},{x:e});if(n){var c=u.expandShapeToKeepDim(l.shape,r);return l.reshape(c)}return l},e.argMin=function(e,t){void 0===t&&(t=0),s.assertArgumentsAreTensors({x:e},"argMin"),null==t&&(t=0);var n=u.parseAxisParam(t,e.shape),r=u.getAxesPermutation(n,e.rank);return null!=r&&(e=e.transpose(r),n=u.getInnerMostAxes(n.length,e.rank)),a.ENV.engine.runKernel(function(t){return t.argMin(e,n[0])},{x:e})},e.argMax=function(e,t){void 0===t&&(t=0),s.assertArgumentsAreTensors({x:e},"argMax"),null==t&&(t=0);var n=u.parseAxisParam(t,e.shape),r=u.getAxesPermutation(n,e.rank);return null!=r&&(e=e.transpose(r),n=u.getInnerMostAxes(n.length,e.rank)),a.ENV.engine.runKernel(function(t){return t.argMax(e,n[0])},{x:e})},e.moments=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1),s.assertArgumentsAreTensors({x:e},"moments");var r=u.parseAxisParam(t,e.shape),i=e.mean(r,n),a=i.shape;return n||(a=u.expandShapeToKeepDim(i.shape,r)),{mean:i,variance:e.toFloat().sub(i.reshape(a)).square().mean(r,n)}},r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"logSumExp",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"sum",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"mean",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"min",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"max",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"argMin",null),r([i.doc({heading:"Operations",subheading:"Reduction"}),l.operation],e,"argMax",null),r([i.doc({heading:"Operations",subheading:"Normalization"}),l.operation],e,"moments",null),e}();n.ReductionOps=p},{"../doc":3,"../environment":5,"../globals":6,"../util":95,"./axis_util":47,"./operation":65,"./ops":66}],71:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./axis_util"),u=e("./operation"),l=function(){function e(){}return e.reverse1d=function(t){return o.assert(1===t.rank,"Error in reverse1D: x must be rank 1 but got\n rank "+t.rank+"."),e.reverse(t,0)},e.reverse2d=function(t,n){return o.assert(2===t.rank,"Error in reverse2D: x must be rank 2 but got\n rank "+t.rank+"."),e.reverse(t,n)},e.reverse3d=function(t,n){return o.assert(3===t.rank,"Error in reverse3D: x must be rank 3 but got\n rank "+t.rank+"."),e.reverse(t,n)},e.reverse4d=function(t,n){return o.assert(4===t.rank,"Error in reverse4D: x must be rank 4 but got\n rank "+t.rank+"."),e.reverse(t,n)},e.reverse=function(e,t){if(o.assertArgumentsAreTensors({x:e},"reverse"),0===e.rank)return e.clone();var n=s.parseAxisParam(t,e.shape);return a.ENV.engine.runKernel(function(t){return t.reverse(e,n)},{x:e},function(e){return{x:function(){return e.reverse(n)}}}).reshapeAs(e)},r([i.doc({heading:"Tensors",subheading:"Slicing and Joining"}),u.operation],e,"reverse",null),e}();n.ReverseOps=l},{"../doc":3,"../environment":5,"../util":95,"./axis_util":47,"./operation":65}],72:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.SELU_SCALEALPHA=1.7580993408473768,n.SELU_SCALE=1.0507009873554805},{}],73:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./operation"),u=e("./slice_util"),l=function(){function e(){}return e.slice1d=function(t,n,r){return o.assert(1===t.rank,"slice1d expects a rank-1 tensor, but got a rank-"+t.rank+" tensor"),e.slice(t,[n],[r])},e.slice2d=function(t,n,r){return o.assert(2===t.rank,"slice1d expects a rank-2 tensor, but got a rank-"+t.rank+" tensor"),e.slice(t,n,r)},e.slice3d=function(t,n,r){return o.assert(3===t.rank,"slice1d expects a rank-3 tensor, but got a rank-"+t.rank+" tensor"),e.slice(t,n,r)},e.slice4d=function(t,n,r){return o.assert(4===t.rank,"slice1d expects a rank-4 tensor, but got a rank-"+t.rank+" tensor"),e.slice(t,n,r)},e.slice=function(e,t,n){if(o.assertArgumentsAreTensors({x:e},"slice"),0===e.rank)throw new Error("Slicing scalar is not possible");var r;r="number"==typeof t?[t].concat(new Array(e.rank-1).fill(0)):t.length=0?t:(o.assert(-1===t,"Bad value in size"),e.shape[n]-r[n])}),u.assertParamsValid(e,r,i);var s=e.shape;return a.ENV.engine.runKernel(function(t){return t.slice(e,r,i)},{x:e},function(e){for(var t=[],n=0;n=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../globals"),o=e("../util"),s=e("./axis_util"),u=e("./operation"),l=e("./ops"),c=function(){function e(){}return e.softmax=function(e,t){if(void 0===t&&(t=-1),o.assertArgumentsAreTensors({logits:e},"softmax"),-1===t&&(t=e.rank-1),t!==e.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+e.rank+" and dim was "+t);return a.customGrad(function(e){var n=e.logSumExp([t],!0),r=e.toFloat().sub(n).exp();return{value:r,gradFunc:function(e){var n=e.mul(r);return n.sub(n.sum([t],!0).mul(r))}}})(e)},e.softmaxCrossEntropy=function(e,t,n){if(void 0===n&&(n=-1),o.assertArgumentsAreTensors({labels:e,logits:t},"softmaxCrossEntropy"),o.assertShapesMatch(e.shape,t.shape,"Error in softmaxCrossEntropy: "),-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+t.rank+" and dim was "+n);return a.customGrad(function(e,t){var r=t.softmax(n);return{value:l.scalar(1e-5).add(r).log().mul(e).neg().sum([n]),gradFunc:function(t){var i=s.expandShapeToKeepDim(t.shape,[n]);return[t.reshape(i).mul(e.toFloat().sub(r)),t.reshape(i).mul(r.sub(e.toFloat()))]}}})(e,t)},r([i.doc({heading:"Operations",subheading:"Normalization"}),u.operation],e,"softmax",null),r([i.doc({heading:"Training",subheading:"Losses",namespace:"losses"}),u.operation],e,"softmaxCrossEntropy",null),e}();n.SoftmaxOps=c},{"../doc":3,"../globals":6,"../util":95,"./axis_util":47,"./operation":65,"./ops":66}],76:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./axis_util"),u=e("./operation"),l=function(){function e(){}return e.transpose=function(e,t){o.assertArgumentsAreTensors({x:e},"transpose"),null==t&&(t=e.shape.map(function(e,t){return t}).reverse());return o.assert(e.rank===t.length,"Error in transpose: rank of input "+e.rank+" must match length of perm "+t+"."),a.ENV.engine.runKernel(function(n){return n.transpose(e,t)},{x:e},function(e){var n=s.getUndoAxesPermutation(t);return{x:function(){return e.transpose(n)}}})},r([i.doc({heading:"Operations",subheading:"Matrices"}),u.operation],e,"transpose",null),e}();n.TransposeOps=l},{"../doc":3,"../environment":5,"../util":95,"./axis_util":47,"./operation":65}],77:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../environment"),o=e("../util"),s=e("./operation"),u=e("./ops"),l=e("./ops"),c=e("./selu_util"),p=function(){function e(){}return e.neg=function(e){o.assertArgumentsAreTensors({x:e},"neg");return a.ENV.engine.runKernel(function(t){return t.neg(e)},{x:e},function(e){return{x:function(){return e.neg()}}})},e.ceil=function(e){o.assertArgumentsAreTensors({x:e},"ceil");return a.ENV.engine.runKernel(function(t){return t.ceil(e)},{x:e},function(e){return{x:function(){return u.zerosLike(e)}}})},e.floor=function(e){o.assertArgumentsAreTensors({x:e},"floor");return a.ENV.engine.runKernel(function(t){return t.floor(e)},{x:e},function(e){return{x:function(){return u.zerosLike(e)}}})},e.sign=function(e){o.assertArgumentsAreTensors({x:e},"sign");return a.ENV.engine.runKernel(function(t){return t.sign(e)},{x:e},function(e){return{x:function(){return u.zerosLike(e)}}})},e.round=function(e){o.assertArgumentsAreTensors({x:e},"round");return a.ENV.engine.runKernel(function(t){return t.round(e)},{x:e},function(e){return{x:function(){return u.zerosLike(e)}}})},e.exp=function(e){o.assertArgumentsAreTensors({x:e},"exp");return a.ENV.engine.runKernel(function(t,n){return n(t.exp(e))},{x:e},function(e,t){var n=t[0];return{x:function(){return e.mulStrict(n)}}})},e.expm1=function(e){o.assertArgumentsAreTensors({x:e},"expm1");return a.ENV.engine.runKernel(function(t){return t.expm1(e)},{x:e},function(t){return{x:function(){return t.mulStrict(e.exp())}}})},e.log=function(e){o.assertArgumentsAreTensors({x:e},"log");return a.ENV.engine.runKernel(function(t){return t.log(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.toFloat())}}})},e.log1p=function(e){o.assertArgumentsAreTensors({x:e},"log1p");return a.ENV.engine.runKernel(function(t){return t.log1p(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.add(u.scalar(1)))}}})},e.sqrt=function(e){o.assertArgumentsAreTensors({x:e},"sqrt");return a.ENV.engine.runKernel(function(t){return t.sqrt(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.toFloat().sqrt().mul(u.scalar(2)))}}})},e.rsqrt=function(e){o.assertArgumentsAreTensors({x:e},"rsqrt");return a.ENV.engine.runKernel(function(t){return t.rsqrt(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.pow(u.scalar(1.5)).mul(u.scalar(2))).neg()}}})},e.square=function(e){o.assertArgumentsAreTensors({x:e},"square");return a.ENV.engine.runKernel(function(t){return t.square(e)},{x:e},function(t){return{x:function(){return t.mulStrict(e.toFloat().mul(u.scalar(2)))}}})},e.reciprocal=function(e){o.assertArgumentsAreTensors({x:e},"reciprocal");return a.ENV.engine.runKernel(function(t){return t.reciprocal(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.square().neg())}}})},e.abs=function(e){o.assertArgumentsAreTensors({x:e},"abs");return a.ENV.engine.runKernel(function(t){return t.abs(e)},{x:e},function(t){return{x:function(){return t.mulStrict(e.toFloat().step(-1))}}})},e.clipByValue=function(e,t,n){o.assertArgumentsAreTensors({x:e},"clipByValue"),o.assert(t<=n,"Error in clip: min ("+t+") must be less than or equal to max ("+n+").");return a.ENV.engine.runKernel(function(r){return r.clip(e,t,n)},{x:e},function(r){return{x:function(){return r.where(e.greater(u.scalar(t)).logicalAnd(e.less(u.scalar(n))),l.zerosLike(r))}}})},e.relu=function(e){if(o.assertArgumentsAreTensors({x:e},"relu"),"bool"===e.dtype)return e.toInt();return a.ENV.engine.runKernel(function(t){return t.relu(e)},{x:e},function(t){var n=e.step();return{x:function(){return t.mulStrict(n.toFloat())}}})},e.elu=function(e){o.assertArgumentsAreTensors({x:e},"elu");return a.ENV.engine.runKernel(function(t,n){return n(t.elu(e))},{x:e},function(e,t){var n=t[0];return{x:function(){return a.ENV.engine.runKernel(function(t){return t.eluDer(e,n)},{dy:e,y:n})}}})},e.selu=function(e){o.assertArgumentsAreTensors({x:e},"selu");return a.ENV.engine.runKernel(function(t){return t.selu(e)},{x:e},function(t){return{x:function(){var n=e.greater(u.scalar(0)),r=u.scalar(c.SELU_SCALEALPHA),i=u.scalar(c.SELU_SCALE),a=t.mul(i),o=t.mul(r).mul(e.toFloat().exp());return u.where(n,a,o)}}})},e.leakyRelu=function(e,t){return void 0===t&&(t=.2),o.assertArgumentsAreTensors({x:e},"leakyRelu"),u.maximum(u.scalar(t).mul(e),e)},e.prelu=function(e,t){o.assertArgumentsAreTensors({x:e,alpha:t},"prelu");var n=u.scalar(0);return u.maximum(n,e).add(t.mul(u.minimum(n,e)))},e.sigmoid=function(e){o.assertArgumentsAreTensors({x:e},"sigmoid");return a.ENV.engine.runKernel(function(t,n){return n(t.sigmoid(e))},{x:e},function(e,t){var n=t[0];return{x:function(){return e.mulStrict(n.mul(u.scalar(1).sub(n)))}}})},e.logSigmoid=function(e){o.assertArgumentsAreTensors({x:e},"logSigmoid");return a.ENV.engine.runKernel(function(t){return t.softplus(e.neg()).neg()},{x:e},function(t){return{x:function(){return t.mulStrict(e.neg().sigmoid())}}})},e.softplus=function(e){o.assertArgumentsAreTensors({x:e},"softplus");return a.ENV.engine.runKernel(function(t){return t.softplus(e)},{x:e},function(t){return{x:function(){return t.mulStrict(e.sigmoid())}}})},e.sin=function(e){o.assertArgumentsAreTensors({x:e},"sin");return a.ENV.engine.runKernel(function(t){return t.sin(e)},{x:e},function(t){return{x:function(){return e.toFloat().cos().mulStrict(t)}}})},e.cos=function(e){o.assertArgumentsAreTensors({x:e},"cos");return a.ENV.engine.runKernel(function(t){return t.cos(e)},{x:e},function(t){return{x:function(){return e.toFloat().sin().neg().mulStrict(t)}}})},e.tan=function(e){o.assertArgumentsAreTensors({x:e},"tan");return a.ENV.engine.runKernel(function(t){return t.tan(e)},{x:e},function(t){return{x:function(){return t.divStrict(e.cos().square())}}})},e.asin=function(t){o.assertArgumentsAreTensors({x:t},"asin");return a.ENV.engine.runKernel(function(e){return e.asin(t)},{x:t},function(n){return{x:function(){return n.divStrict(e.sqrt(u.scalar(1).sub(t.toFloat().square())))}}})},e.acos=function(t){o.assertArgumentsAreTensors({x:t},"acos");return a.ENV.engine.runKernel(function(e){return e.acos(t)},{x:t},function(n){return{x:function(){return n.divStrict(e.sqrt(u.scalar(1).sub(t.toFloat().square()))).neg()}}})},e.atan=function(e){o.assertArgumentsAreTensors({x:e},"atan");return a.ENV.engine.runKernel(function(t){return t.atan(e)},{x:e},function(t){return{x:function(){return t.divStrict(u.scalar(1).add(e.toFloat().square()))}}})},e.sinh=function(e){o.assertArgumentsAreTensors({x:e},"sinh");return a.ENV.engine.runKernel(function(t){return t.sinh(e)},{x:e},function(t){return{x:function(){return e.toFloat().cosh().mulStrict(t)}}})},e.cosh=function(e){o.assertArgumentsAreTensors({x:e},"cosh");return a.ENV.engine.runKernel(function(t){return t.cosh(e)},{x:e},function(t){return{x:function(){return e.toFloat().sinh().mulStrict(t)}}})},e.tanh=function(e){o.assertArgumentsAreTensors({x:e},"tanh");return a.ENV.engine.runKernel(function(t,n){return n(t.tanh(e))},{x:e},function(e,t){var n=t[0];return{x:function(){return u.scalar(1).sub(n.square()).mulStrict(e)}}})},e.asinh=function(t){o.assertArgumentsAreTensors({x:t},"asinh");return a.ENV.engine.runKernel(function(e){return e.asinh(t)},{x:t},function(n){return{x:function(){return n.divStrict(e.sqrt(u.scalar(1).add(t.toFloat().square())))}}})},e.acosh=function(t){o.assertArgumentsAreTensors({x:t},"acosh");return a.ENV.engine.runKernel(function(e){return e.acosh(t)},{x:t},function(n){return{x:function(){return n.divStrict(e.sqrt(t.toFloat().square().sub(u.scalar(1))))}}})},e.atanh=function(e){o.assertArgumentsAreTensors({x:e},"atanh");return a.ENV.engine.runKernel(function(t){return t.atanh(e)},{x:e},function(t){return{x:function(){return t.divStrict(u.scalar(1).sub(e.toFloat().square()))}}})},e.erf=function(e){o.assert("int32"===e.dtype||"float32"===e.dtype,"Input dtype must be `int32` or `float32`."),"int32"===e.dtype&&(e=e.toFloat());return a.ENV.engine.runKernel(function(t){return t.erf(e)},{x:e},function(t){return{x:function(){return t.mulStrict(u.scalar(2/Math.sqrt(Math.PI)).mul(e.square().neg().exp()))}}})},e.step=function(e,t){void 0===t&&(t=0),o.assertArgumentsAreTensors({x:e},"step");return a.ENV.engine.runKernel(function(n){return n.step(e,t)},{x:e},function(e){return{x:function(){return u.zerosLike(e)}}})},r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"neg",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"ceil",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"floor",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"sign",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"round",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"exp",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"expm1",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"log",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"log1p",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"sqrt",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"rsqrt",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"square",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"reciprocal",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"abs",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"clipByValue",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"relu",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"elu",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"selu",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"leakyRelu",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"prelu",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"sigmoid",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"logSigmoid",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"softplus",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"sin",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"cos",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"tan",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"asin",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"acos",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"atan",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"sinh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"cosh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"tanh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"asinh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"acosh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"atanh",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"erf",null),r([i.doc({heading:"Operations",subheading:"Basic math"}),s.operation],e,"step",null),e}();n.UnaryOps=p},{"../doc":3,"../environment":5,"../util":95,"./operation":65,"./ops":66,"./selu_util":72}],78:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n,r){void 0===r&&(r=1e-8);var i=e.call(this)||this;return i.accumulatedGrads={},i.accumulatedUpdates={},i.c=a.keep(o.scalar(-t)),i.epsilon=a.keep(o.scalar(r)),i.rho=a.keep(o.scalar(n)),i.oneMinusRho=a.keep(o.scalar(1-n)),i}return r(t,e),t.prototype.applyGradients=function(e){var t=this,n=this;for(var r in e)!function(r){var s=i.ENV.engine.registeredVariables[r];null==n.accumulatedGrads[r]&&a.tidy(function(){t.accumulatedGrads[r]=o.zerosLike(s).variable(!1)});null==n.accumulatedUpdates[r]&&a.tidy(function(){t.accumulatedUpdates[r]=o.zerosLike(s).variable(!1)});var u=e[r],l=n.accumulatedGrads[r],c=n.accumulatedUpdates[r];a.tidy(function(){var e=t.rho.mul(l).add(t.oneMinusRho.mul(u.square())),n=c.add(t.epsilon).sqrt().div(l.add(t.epsilon).sqrt()).mul(u),i=t.rho.mul(c).add(t.oneMinusRho.mul(n.square()));t.accumulatedGrads[r].assign(e),t.accumulatedUpdates[r].assign(i);var a=t.c.mul(n).add(s);s.assign(a)})}(r)},t.prototype.dispose=function(){var e=this;this.c.dispose(),this.epsilon.dispose(),this.rho.dispose(),this.oneMinusRho.dispose(),null!=this.accumulatedUpdates&&(Object.keys(this.accumulatedUpdates).forEach(function(t){return e.accumulatedUpdates[t].dispose()}),Object.keys(this.accumulatedGrads).forEach(function(t){return e.accumulatedGrads[t].dispose()}))},t}(e("./optimizer").Optimizer);n.AdadeltaOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],79:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n){void 0===n&&(n=.1);var r=e.call(this)||this;return r.learningRate=t,r.initialAccumulatorValue=n,r.accumulatedGrads={},r.c=a.keep(o.scalar(-t)),r.epsilon=a.keep(o.scalar(1e-8)),r}return r(t,e),t.prototype.applyGradients=function(e){var t=this,n=this;for(var r in e)!function(r){var s=i.ENV.engine.registeredVariables[r];null==n.accumulatedGrads[r]&&a.tidy(function(){t.accumulatedGrads[r]=o.fill(s.shape,t.initialAccumulatorValue).variable(!1)});var u=e[r],l=n.accumulatedGrads[r];a.tidy(function(){var e=l.add(u.square());t.accumulatedGrads[r].assign(e);var n=t.c.mul(u.div(e.add(t.epsilon).sqrt())).add(s);s.assign(n)})}(r)},t.prototype.dispose=function(){var e=this;this.epsilon.dispose(),this.c.dispose(),null!=this.accumulatedGrads&&Object.keys(this.accumulatedGrads).forEach(function(t){return e.accumulatedGrads[t].dispose()})},t}(e("./optimizer").Optimizer);n.AdagradOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],80:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n,r,i){void 0===i&&(i=1e-8);var s=e.call(this)||this;return s.learningRate=t,s.accumulatedFirstMoment={},s.accumulatedSecondMoment={},s.c=a.keep(o.scalar(-t)),s.eps=a.keep(o.scalar(i)),s.beta1=a.keep(o.scalar(n)),s.beta2=a.keep(o.scalar(r)),a.tidy(function(){s.accBeta1=o.scalar(n).variable(),s.accBeta2=o.scalar(r).variable()}),s.oneMinusBeta1=a.keep(o.scalar(1-n)),s.oneMinusBeta2=a.keep(o.scalar(1-r)),s.one=a.keep(o.scalar(1)),s}return r(t,e),t.prototype.applyGradients=function(e){var t=this;a.tidy(function(){var n=t.one.sub(t.accBeta1),r=t.one.sub(t.accBeta2);for(var a in e){var s=i.ENV.engine.registeredVariables[a];if(null==t.accumulatedFirstMoment[a]){u=!1;t.accumulatedFirstMoment[a]=o.zerosLike(s).variable(u)}if(null==t.accumulatedSecondMoment[a]){var u=!1;t.accumulatedSecondMoment[a]=o.zerosLike(s).variable(u)}var l=e[a],c=t.accumulatedFirstMoment[a],p=t.accumulatedSecondMoment[a],h=t.beta1.mul(c).add(t.oneMinusBeta1.mul(l)),d=t.beta2.mul(p).add(t.oneMinusBeta2.mul(l.square())),f=h.div(n),g=d.div(r);t.accumulatedFirstMoment[a].assign(h),t.accumulatedSecondMoment[a].assign(d);var m=t.c.mul(f.div(t.eps.add(g.sqrt()))).add(s);s.assign(m)}t.accBeta1.assign(t.accBeta1.mul(t.beta1)),t.accBeta2.assign(t.accBeta2.mul(t.beta2))})},t.prototype.dispose=function(){var e=this;this.c.dispose(),this.eps.dispose(),this.beta1.dispose(),this.beta2.dispose(),this.accBeta1.dispose(),this.accBeta2.dispose(),this.oneMinusBeta1.dispose(),this.oneMinusBeta2.dispose(),this.one.dispose(),null!=this.accumulatedFirstMoment&&Object.keys(this.accumulatedFirstMoment).forEach(function(t){return e.accumulatedFirstMoment[t].dispose()}),null!=this.accumulatedSecondMoment&&Object.keys(this.accumulatedSecondMoment).forEach(function(t){return e.accumulatedSecondMoment[t].dispose()})},t}(e("./optimizer").Optimizer);n.AdamOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],81:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n,r,i,s){void 0===i&&(i=1e-8),void 0===s&&(s=0);var u=e.call(this)||this;return u.learningRate=t,u.accumulatedFirstMoment={},u.accumulatedWeightedInfNorm={},u.c=a.keep(o.scalar(-t)),u.eps=a.keep(o.scalar(i)),u.beta1=a.keep(o.scalar(n)),u.beta2=a.keep(o.scalar(r)),u.decay=a.keep(o.scalar(s)),a.tidy(function(){u.iteration=o.scalar(0).variable(),u.accBeta1=o.scalar(n).variable()}),u.oneMinusBeta1=a.keep(o.scalar(1-n)),u.one=a.keep(o.scalar(1)),u}return r(t,e),t.prototype.applyGradients=function(e){var t=this;a.tidy(function(){var n=t.one.sub(t.accBeta1),r=t.c.div(t.one.add(t.decay.mul(t.iteration)));for(var a in e){var s=i.ENV.engine.registeredVariables[a];if(null==t.accumulatedFirstMoment[a]){u=!1;t.accumulatedFirstMoment[a]=o.zerosLike(s).variable(u)}if(null==t.accumulatedWeightedInfNorm[a]){var u=!1;t.accumulatedWeightedInfNorm[a]=o.zerosLike(s).variable(u)}var l=e[a],c=t.accumulatedFirstMoment[a],p=t.accumulatedWeightedInfNorm[a],h=t.beta1.mul(c).add(t.oneMinusBeta1.mul(l)),d=t.beta2.mul(p),f=l.abs(),g=d.maximum(f);t.accumulatedFirstMoment[a].assign(h),t.accumulatedWeightedInfNorm[a].assign(g);var m=r.div(n).mul(h.div(t.eps.add(g))).add(s);s.assign(m)}t.iteration.assign(t.iteration.add(t.one)),t.accBeta1.assign(t.accBeta1.mul(t.beta1))})},t.prototype.dispose=function(){var e=this;this.c.dispose(),this.eps.dispose(),this.accBeta1.dispose(),this.beta1.dispose(),this.beta2.dispose(),this.oneMinusBeta1.dispose(),this.decay.dispose(),this.iteration.dispose(),this.one.dispose(),null!=this.accumulatedFirstMoment&&Object.keys(this.accumulatedFirstMoment).forEach(function(t){return e.accumulatedFirstMoment[t].dispose()}),null!=this.accumulatedWeightedInfNorm&&Object.keys(this.accumulatedWeightedInfNorm).forEach(function(t){return e.accumulatedWeightedInfNorm[t].dispose()})},t}(e("./optimizer").Optimizer);n.AdamaxOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],82:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n,r){void 0===r&&(r=!1);var i=e.call(this,t)||this;return i.learningRate=t,i.momentum=n,i.useNesterov=r,i.m=o.scalar(i.momentum),i.accumulations={},i}return r(t,e),t.prototype.applyGradients=function(e){var t=this,n=this;for(var r in e)!function(r){var s=i.ENV.engine.registeredVariables[r];null==n.accumulations[r]&&a.tidy(function(){t.accumulations[r]=o.zerosLike(s).variable(!1)});var u=n.accumulations[r],l=e[r];a.tidy(function(){var e,n=t.m.mul(u).add(l);e=t.useNesterov?t.c.mul(l.add(n.mul(t.m))).add(s):t.c.mul(n).add(s),t.accumulations[r].assign(n),s.assign(e)})}(r)},t.prototype.dispose=function(){if(e.prototype.dispose.call(this),this.m.dispose(),null!=this.accumulations)for(var t in this.accumulations)this.accumulations[t].dispose()},t.prototype.setMomentum=function(e){this.momentum=e},t}(e("./sgd_optimizer").SGDOptimizer);n.MomentumOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./sgd_optimizer":86}],83:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("../globals"),o=function(){function e(){}return e.prototype.minimize=function(e,t,n){void 0===t&&(t=!1);var r=this.computeGradients(e,n),i=r.value,a=r.grads;return this.applyGradients(a),Object.keys(a).forEach(function(e){return a[e].dispose()}),t?i:(i.dispose(),null)},e.prototype.computeGradients=function(e,t){return a.variableGrads(e,t)},r([i.doc({heading:"Training",subheading:"Optimizers"})],e.prototype,"minimize",null),e=r([i.doc({heading:"Training",subheading:"Classes",namespace:"train"})],e)}();n.Optimizer=o},{"../doc":3,"../globals":6}],84:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../doc"),a=e("./adadelta_optimizer"),o=e("./adagrad_optimizer"),s=e("./adam_optimizer"),u=e("./adamax_optimizer"),l=e("./momentum_optimizer"),c=e("./rmsprop_optimizer"),p=e("./sgd_optimizer"),h=function(){function e(){}return e.sgd=function(e){return new p.SGDOptimizer(e)},e.momentum=function(e,t,n){return void 0===n&&(n=!1),new l.MomentumOptimizer(e,t,n)},e.rmsprop=function(e,t,n,r,i){return void 0===t&&(t=.9),void 0===n&&(n=0),void 0===r&&(r=1e-8),void 0===i&&(i=!1),new c.RMSPropOptimizer(e,t,n,r,i)},e.adam=function(e,t,n,r){return void 0===e&&(e=.001),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=1e-8),new s.AdamOptimizer(e,t,n,r)},e.adadelta=function(e,t,n){return void 0===e&&(e=.001),void 0===t&&(t=.95),void 0===n&&(n=1e-8),new a.AdadeltaOptimizer(e,t,n)},e.adamax=function(e,t,n,r,i){return void 0===e&&(e=.002),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=1e-8),void 0===i&&(i=0),new u.AdamaxOptimizer(e,t,n,r,i)},e.adagrad=function(e,t){return void 0===t&&(t=.1),new o.AdagradOptimizer(e,t)},r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"sgd",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"momentum",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"rmsprop",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"adam",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"adadelta",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"adamax",null),r([i.doc({heading:"Training",subheading:"Optimizers",namespace:"train"})],e,"adagrad",null),e}();n.OptimizerConstructors=h},{"../doc":3,"./adadelta_optimizer":78,"./adagrad_optimizer":79,"./adam_optimizer":80,"./adamax_optimizer":81,"./momentum_optimizer":82,"./rmsprop_optimizer":85,"./sgd_optimizer":86}],85:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t,n,r,i,s){void 0===n&&(n=.9),void 0===r&&(r=0),void 0===i&&(i=1e-8),void 0===s&&(s=!1);var u=e.call(this)||this;return u.learningRate=t,u.accumulatedMeanSquares={},u.accumulatedMeanGrads={},u.accumulatedMoments={},u.c=a.keep(o.scalar(t)),u.epsilon=a.keep(o.scalar(i)),u.decay=a.keep(o.scalar(n)),u.momentum=a.keep(o.scalar(r)),u.oneMinusDecay=a.keep(o.scalar(1-n)),u.centered=s,u}return r(t,e),t.prototype.applyGradients=function(e){var t=this,n=this;for(var r in e)!function(r){var s=i.ENV.engine.registeredVariables[r];null==n.accumulatedMeanSquares[r]&&a.tidy(function(){t.accumulatedMeanSquares[r]=o.zerosLike(s).variable(!1)});null==n.accumulatedMeanGrads[r]&&n.centered&&a.tidy(function(){t.accumulatedMeanGrads[r]=o.zerosLike(s).variable(!1)});null==n.accumulatedMoments[r]&&a.tidy(function(){t.accumulatedMoments[r]=o.zerosLike(s).variable(!1)});var u=n.accumulatedMeanSquares[r],l=n.accumulatedMeanGrads[r],c=n.accumulatedMoments[r],p=e[r];a.tidy(function(){var e=t.decay.mul(u).add(t.oneMinusDecay.mul(p.square()));if(t.centered){var n=t.decay.mul(l).add(t.oneMinusDecay.mul(p)),i=t.momentum.mul(c).add(t.c.mul(p).div(e.sub(n.square().add(t.epsilon)).sqrt()));t.accumulatedMeanSquares[r].assign(e),t.accumulatedMeanGrads[r].assign(n),t.accumulatedMoments[r].assign(i),o=s.sub(i),s.assign(o)}else{var a=t.decay.mul(u).add(t.oneMinusDecay.mul(p.square())),i=t.momentum.mul(c).add(t.c.mul(p).div(a.add(t.epsilon).sqrt()));t.accumulatedMeanSquares[r].assign(a),t.accumulatedMoments[r].assign(i);var o=s.sub(i);s.assign(o)}})}(r)},t.prototype.dispose=function(){var e=this;this.c.dispose(),this.epsilon.dispose(),this.decay.dispose(),this.momentum.dispose(),this.oneMinusDecay.dispose(),null!=this.accumulatedMeanSquares&&Object.keys(this.accumulatedMeanSquares).forEach(function(t){return e.accumulatedMeanSquares[t].dispose()}),null!=this.accumulatedMeanGrads&&this.centered&&Object.keys(this.accumulatedMeanGrads).forEach(function(t){return e.accumulatedMeanGrads[t].dispose()}),null!=this.accumulatedMoments&&Object.keys(this.accumulatedMoments).forEach(function(t){return e.accumulatedMoments[t].dispose()})},t}(e("./optimizer").Optimizer);n.RMSPropOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],86:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../environment"),a=e("../globals"),o=e("../ops/ops"),s=function(e){function t(t){var n=e.call(this)||this;return n.learningRate=t,n.setLearningRate(t),n}return r(t,e),t.prototype.applyGradients=function(e){var t=this;Object.keys(e).forEach(function(n){var r=e[n],o=i.ENV.engine.registeredVariables[n];a.tidy(function(){var e=t.c.mul(r).add(o);o.assign(e)})})},t.prototype.setLearningRate=function(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=a.keep(o.scalar(-e))},t.prototype.dispose=function(){this.c.dispose()},t}(e("./optimizer").Optimizer);n.SGDOptimizer=s},{"../environment":5,"../globals":6,"../ops/ops":66,"./optimizer":83}],87:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./util"),i=function(){function e(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new a)}return e.prototype.profileKernel=function(e,t){var n,i=this,a=this.backendTimer.time(function(){n=t()}),o=n.dataSync();return r.checkForNaN(o,n.dtype,e),a.then(function(t){i.logger.logKernelProfile(e,n,o,t.kernelMs)}),n},e}();n.Profiler=i;var a=function(){function e(){}return e.prototype.logKernelProfile=function(e,t,n,i){var a=r.rightPad(i+"ms",9),o=r.rightPad(e,25),s=t.rank,u=t.size,l=r.rightPad(t.shape.toString(),14);console.log("%c"+o+"\t%c"+a+"\t%c"+s+"D "+l+"\t%c"+u,"font-weight:bold","color:red","color:blue","color: orange")},e}();n.Logger=a},{"./util":95}],88:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./util");n.getFilteredNodesXToY=function(e,t,n){for(var r={},i={},a=0;a=0;a--){var h=(g=e[a]).inputs,d=[];for(d.push(g.output),l=0;l=0;n--){var i=t[n],a=e[i.output.id];if(null==i.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+i.name+".");var o=i.gradient(a);for(var s in i.inputs){if(!(s in o))throw new Error("Cannot backprop through input "+s+". Available gradients found: "+Object.keys(o)+".");var u=o[s](),l=i.inputs[s];if(!r.arraysEqual(u.shape,l.shape))throw new Error("Error in gradient for op "+i.name+". The gradient of input '"+s+"' has shape '"+u.shape+"', which does not match the shape of the input '"+l.shape+"'");if(null==e[l.id])e[l.id]=u;else{var c=e[l.id];e[l.id]=c.add(u),c.dispose()}}}}},{"./util":95}],89:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t<2)return[];var n=new Array(t-1);n[t-2]=e[t-1];for(var r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),a=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(o=a[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(a,n[1])).done)return o;switch(a=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]1)for(var o=0;os){var p=Array.from(e.subarray(0,u)),h=Array.from(e.subarray(l-u,l));return["["+p.map(function(e,t){return i(e,r[t])}).join(", ")+", ..., "+h.map(function(e,t){return i(e,r[l-u+t])}).join(", ")+"]"]}return["["+Array.from(e).map(function(e,t){return i(e,r[t])}).join(", ")+"]"]}var d=t.slice(1),f=n.slice(1),g=n[0],m=[];if(l>s){for(x=0;xn)}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./tensor"),o=e("./util");n.WEBGL_ENVS={BACKEND:"test-webgl"},n.CPU_ENVS={BACKEND:"test-cpu"},n.ALL_ENVS={},n.TEST_EPSILON=.001,n.expectArraysClose=r,n.expectPromiseToFail=function(e,t){e().then(function(){return t.fail()},function(){return t()})},n.expectArraysEqual=function(e,t){return r(e,t,0)},n.expectNumbersClose=function(e,t,r){if(void 0===r&&(r=n.TEST_EPSILON),!i(e,t,r))throw new Error("Numbers differ: actual === "+e+", expected === "+t)},n.expectValuesInRange=function(e,t,n){var r;r=e instanceof a.Tensor?e.dataSync():e;for(var i=0;in)throw new Error("Value out of range:"+r[i]+" low: "+t+", high: "+n)}},{"./tensor":89,"./util":95}],92:[function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("./doc"),a=e("./environment"),o=e("./util"),s=function(){function e(){}return e.tidy=function(e,t,n){void 0===n&&(n=!1);var r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}a.ENV.engine.startScope(r,n);var i=t();return i instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),a.ENV.engine.endScope(i,n),i},e.dispose=function(e){o.extractTensorsFromAny(e).forEach(function(e){return e.dispose()})},e.keep=function(e){return a.ENV.engine.keep(e)},e.time=function(e){return a.ENV.engine.time(e)},r([i.doc({heading:"Performance",subheading:"Memory"})],e,"tidy",null),r([i.doc({heading:"Performance",subheading:"Memory"})],e,"keep",null),r([i.doc({heading:"Performance",subheading:"Timing"})],e,"time",null),e}();n.Tracking=s},{"./doc":3,"./environment":5,"./util":95}],93:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./optimizers/adadelta_optimizer"),i=e("./optimizers/adagrad_optimizer"),a=e("./optimizers/adam_optimizer"),o=e("./optimizers/adamax_optimizer"),s=e("./optimizers/momentum_optimizer"),u=e("./optimizers/optimizer_constructors"),l=e("./optimizers/rmsprop_optimizer"),c=e("./optimizers/sgd_optimizer");s.MomentumOptimizer,c.SGDOptimizer,r.AdadeltaOptimizer,i.AdagradOptimizer,l.RMSPropOptimizer,o.AdamaxOptimizer,a.AdamOptimizer,n.train={sgd:u.OptimizerConstructors.sgd,momentum:u.OptimizerConstructors.momentum,adadelta:u.OptimizerConstructors.adadelta,adagrad:u.OptimizerConstructors.adagrad,rmsprop:u.OptimizerConstructors.rmsprop,adamax:u.OptimizerConstructors.adamax,adam:u.OptimizerConstructors.adam}},{"./optimizers/adadelta_optimizer":78,"./optimizers/adagrad_optimizer":79,"./optimizers/adam_optimizer":80,"./optimizers/adamax_optimizer":81,"./optimizers/momentum_optimizer":82,"./optimizers/optimizer_constructors":84,"./optimizers/rmsprop_optimizer":85,"./optimizers/sgd_optimizer":86}],94:[function(e,t,n){"use strict";function r(e,t){return s[e][t]}Object.defineProperty(n,"__esModule",{value:!0});!function(e){e.float32="float32",e.int32="int32",e.bool="bool"}(n.DType||(n.DType={}));!function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(n.Rank||(n.Rank={}));var i;!function(e){e.float32="float32",e.int32="int32",e.bool="int32"}(i||(i={}));var a;!function(e){e.float32="float32",e.int32="int32",e.bool="bool"}(a||(a={}));var o;!function(e){e.float32="float32",e.int32="float32",e.bool="float32"}(o||(o={}));var s={float32:o,int32:i,bool:a};n.upcastType=r,n.sumOutType=function(e){return r(e,"int32")}},{}],95:[function(e,t,n){"use strict";function r(e,t,n){a(e instanceof h.Tensor,"Argument '"+t+"' passed to '"+n+"' must be a Tensor, but got "+typeof e+".")}function i(e){for(var t=e.length,n=0,r=0;t>0;)r=Math.random()*t|0,n=e[--t],e[t]=e[r],e[r]=n}function a(e,t){if(!e)throw new Error(t)}function o(e,t){if(void 0===t&&(t=[]),Array.isArray(e))for(var n=0;n1;--t)if(e%t==0)return[t,e/t];return[1,e]},n.createShuffledIndices=function(e){for(var t=new Uint32Array(e),n=0;n=n?i():setTimeout(o,s)}};setTimeout(o,0)})},n.getQueryParams=function(e){var t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(e){for(var n=[],r=1;r0&&t!==n)throw Error("Size("+t+") must match the product of shape "+e);return e}if(t%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+t+" / "+n);var a=e.slice();return a[r]=t/n,a},n.squeezeShape=function(e,t){for(var n=[],r=[],i=0,a=0;a1)throw new Error("Can't squeeze axis "+a+" since its dim '"+e[a]+"' is not 1");(null==t[i]||t[i]>a)&&1===e[a]&&(n.push(e[a]),r.push(a)),t[i]<=a&&i++}e[a]>1&&(n.push(e[a]),r.push(a))}return{newShape:n,keptDims:r}},n.getTypedArrayFromDType=function(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error("Unknown data type "+e);n=new Uint8Array(t)}return n},n.isTensorInList=function(e,t){for(var n=0;n0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]0?t.reduce(function(e,t){return e*t}):1},n.cast=function(e,t){return e.asType(t)},n.reshape=u,n.transpose=l,n.permuteDimensions=l,n.reverse=c,n.expandDims=p,n.squeeze=function(e,t){return H.squeeze(e,[t])},n.temporalPadding=function(e,t){if(3!==o(e))throw new Y.ValueError("temporalPadding expects input tensor to be 3-D, but received a "+o(e)+"-D tensor.");if(null==t&&(t=[1,1]),2!==t.length)throw new Y.ValueError("temporalPadding expects input padding pattern to be a length-2 array, but received a length-"+t.length+" array.");var n=[[0,0],t,[0,0]];return H.pad(e,n)},n.spatial2dPadding=function(e,t,n){if(4!==o(e))throw new Y.ValueError("temporalPadding expects input tensor to be 4-D, but received a "+o(e)+"-D tensor.");if(null==t&&(t=[[1,1],[1,1]]),2!==t.length||2!==t[0].length||2!==t[1].length)throw new Y.ValueError("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==n&&(n=ee.imageDataFormat()),"channelsLast"!==n&&"channelsFirst"!==n)throw new Y.ValueError("Unknown data format: "+n+". Supported data formats are 'channelsLast' and 'channelsFirst.");var r;return r="channelsFirst"===n?[[0,0],[0,0],t[0],t[1]]:[[0,0],t[0],t[1],[0,0]],H.pad(e,r)},n.repeat=function(e,t){if(2!==e.shape.length)throw new Y.ValueError("repeat() expects a rank-2 tensor, but received a rank-"+e.shape.length+" tensor.");return v(p(e,1),[1,t,1])},n.flatten=h,n.batchFlatten=function(e){if(o(e)<=1)throw new Y.ValueError("batchFlatten requires a minimum rank of 2. Got rank: "+o(e)+".");return u(e,[e.shape[0],J.arrayProd(e.shape,1)])},n.sliceAlongFirstAxis=d,n.sliceAlongLastAxis=function(e,t,n){switch(e.rank){case 1:return H.slice1d(e,t,n);case 2:return H.slice2d(e,[0,t],[e.shape[0],n]);case 3:return H.slice3d(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return H.slice4d(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new Y.ValueError("sliceAlongLastAxis() received an unsupported tensor rank: "+e.rank)}},n.normalizeBatchInTraining=function(e,t,n,r,i){return void 0===i&&(i=.001),K.util.arraysEqual(r.slice().sort(),J.range(0,o(e)-1))?f(e,t,n,r,i):g(e,t,n,r,i)},n.concatenate=function(e,t){void 0===t&&(t=-1);var n;return t<0&&(t=0!==(n=o(e[0]))?n:0),t===o(e[0])&&(t=-1),H.concat(e,t)},n.concatAlongFirstAxis=m,n.tile=v,n.variable=function(e,t,n,r){return new Q.LayerVariable(e,t,n,!0,r)},n.batchGetValue=function(e){return e.map(function(e){return e.read()})},n.batchSetValue=function(e){e.map(function(e){e[0].write(e[1])})},n.zeros=y,n.zerosVariable=function(e,t,n){return new Q.LayerVariable(y(e),t,n)},n.zerosLike=function(e,t,n){return new Q.LayerVariable(H.zerosLike(e),t,n)},n.ones=function(e,t){return H.ones(e)},n.onesVariable=function(e,t,n){var r=H.ones(e);return new Q.LayerVariable(r,t,n)},n.onesLike=function(e,t,n){var r=H.onesLike(e);return new Q.LayerVariable(r,t,n)},n.identity=function(e){return e.clone()},n.eye=b,n.eyeVariable=function(e,t,n){return new Q.LayerVariable(b(e,t),t,n)},n.neg=w,n.add=function(e,t){return H.add(e,t)},n.subtract=x,n.multiply=A,n.divide=E,n.scalarTimesArray=_,n.scalarPlusArray=T,n.randomUniform=S,n.randomUniformVariable=function(e,t,n,r,i,a){return void 0===a&&(a="randomUniform"),new Q.LayerVariable(S(e,t,n,r,i),r,a)},n.truncatedNormal=C,n.truncatedNormalVariable=function(e,t,n,r,i,a){return void 0===t&&(t=0),void 0===n&&(n=1),void 0===a&&(a="truncatedNormal"),new Q.LayerVariable(C(e,t,n,r,i),r,a)},n.randomNormal=O,n.randomNormalVariable=function(e,t,n,r,i,a){return void 0===t&&(t=0),void 0===n&&(n=1),void 0===a&&(a="randomNormal"),new Q.LayerVariable(O(e,t,n,r,i),r,a)},n.update=function(e,t){return e.write(t)},n.updateAdd=function(e,t){return e.write(H.add(e.read(),t))},n.updateSub=function(e,t){return e.write(H.sub(e.read(),t))},n.dot=function(e,t){if(2!==o(t))throw new Y.NotImplementedError("dot support for y other than rank 2 is not yet implemented: y shape = "+a);if(2===o(e))return H.matMul(e,t);if(3===o(e)){var n=e.shape[0],r=e.shape[1],i=e.shape[2];return e=e.reshape([n*r,i]),H.matMul(e,t).reshape([n,r,t.shape[1]])}throw new Y.NotImplementedError("dot support for x of rank "+o(e)+" is not yet implemented: x shape = "+a)},n.sign=k,n.qr=function(e){if(2!==e.shape.length)throw new Y.ValueError("qr() requires a 2D Tensor, but got a "+e.shape.length+"D Tensor.");if(e.shape[0]= x.shape[1], but got shape: ["+e.shape+"]");for(var t=e.shape[0],n=e.shape[1],r=b(t),i=e,a=K.tensor2d([[1]],[1,1]),o=0;o0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]0){var n=e+"_"+t;return s.set(n,1),n}return e};var c=new RegExp(/^[A-Za-z][A-Za-z0-9\._\/]*$/);n.isValidTensorName=i},{"./errors":107,"./utils/generic_utils":130}],103:[function(e,t,n){"use strict";function r(e,t){return u.sqrt(u.sum(u.square(e),t,!0))}function i(e,t){return void 0===t&&(t={}),c.deserializeKerasObject(e,c.ClassNameMap.getMap().pythonClassNameMap,t,"constraint")}var a=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var s=e("@tensorflow/tfjs-core"),u=e("./backend/tfjs_backend"),l=e("./types"),c=e("./utils/generic_utils"),p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.getConfig=function(){return{}},t=o([s.doc({heading:"Constraints",subheading:"Classes",namespace:"constraints"})],t)}(l.Serializable);n.Constraint=p;var h=function(e){function t(t){var n=e.call(this)||this;return n.defaultMaxValue=2,n.defaultAxis=0,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}return a(t,e),t.prototype.apply=function(e){var t=r(e,this.axis),n=u.clip(t,0,this.maxValue);return u.multiply(e,u.divide(n,u.scalarPlusArray(u.getScalar(u.epsilon()),t)))},t.prototype.getClassName=function(){return"MaxNorm"},t.prototype.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},t}(p);n.MaxNorm=h,c.ClassNameMap.register("MaxNorm",h);var d=function(e){function t(t){var n=e.call(this)||this;return n.defaultAxis=0,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}return a(t,e),t.prototype.apply=function(e){return u.divide(e,u.scalarPlusArray(u.getScalar(u.epsilon()),r(e,this.axis)))},t.prototype.getClassName=function(){return"UnitNorm"},t.prototype.getConfig=function(){return{axis:this.axis}},t}(p);n.UnitNorm=d,c.ClassNameMap.register("UnitNorm",d);var f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.apply=function(e){return u.relu(e)},t.prototype.getClassName=function(){return"NonNeg"},t}(p);n.NonNeg=f,c.ClassNameMap.register("NonNeg",f);var g=function(e){function t(t){var n=e.call(this)||this;return n.defaultMinValue=0,n.defaultMaxValue=1,n.defaultRate=1,n.defaultAxis=0,n.minValue=null!=t.minValue?t.minValue:n.defaultMinValue,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.rate=null!=t.rate?t.rate:n.defaultRate,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}return a(t,e),t.prototype.apply=function(e){var t=r(e,this.axis),n=u.add(u.scalarTimesArray(u.getScalar(this.rate),u.clip(t,this.minValue,this.maxValue)),u.scalarTimesArray(u.getScalar(1-this.rate),t));return u.multiply(e,u.divide(n,u.scalarPlusArray(u.getScalar(u.epsilon()),t)))},t.prototype.getClassName=function(){return"MinMaxNorm"},t.prototype.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},t}(p);n.MinMaxNorm=g,c.ClassNameMap.register("MinMaxNorm",g),n.CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"},n.serializeConstraint=function(e){return c.serializeKerasObject(e)},n.deserializeConstraint=i,n.getConstraint=function(e){return null==e?null:"string"==typeof e?i({className:e in n.CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP?n.CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP[e]:e,config:{}}):e instanceof p?e:i(e)}},{"./backend/tfjs_backend":100,"./types":128,"./utils/generic_utils":130,"@tensorflow/tfjs-core":8}],104:[function(e,t,n){"use strict";function r(e,t){if(null!=e.dtype&&e.dtype!==t.dtype)throw new o.ValueError("The dtype of the feed ("+t.dtype+") is incompatible with that of the key '"+e.name+"' ("+e.dtype+").");if(null!=e.shape){if(e.shape.length!==t.shape.length)throw new o.ValueError("The rank of feed ("+t.shape.length+") does not match the rank of the key ("+e.shape.length+").");for(var n=0;n0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];var r=t.inboundNodes[n];if(0===r.inboundLayers.length)return r.inputTensors;for(var i=[],o=0;o0)throw new f.ValueError(p.length+" of "+r+" weights are not set: "+p);d.batchSetValue(l)}function l(e,t,n){void 0===n&&(n=!1);for(var r=e.keras_version,i=e.backend,a=t.map(function(e){return e.name}),u={},l=0,c=t;l=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var h=e("@tensorflow/tfjs-core"),d=e("../backend/tfjs_backend"),f=e("../errors"),g=e("../layers/serialization"),m=e("../types"),v=e("../utils/generic_utils"),y=e("../utils/serialization_utils"),b=function(){return function(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}();n.InputSpec=b;var w=0,x=function(){function e(e,t){this.callArgs=t,this.id=w++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(var n=0,r=e.inboundLayers;n1)throw new f.AttributeError("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(0===this.inboundNodes.length)throw new f.AttributeError("Layer "+this.name+" is not connected, no input to return.");return v.singletonOrArray(this.getNodeAtIndex(0,"input").inputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){if(0===this.inboundNodes.length)throw new f.AttributeError("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new f.AttributeError("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return v.singletonOrArray(this.getNodeAtIndex(0,"output").outputTensors)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"losses",{get:function(){return this._losses},enumerable:!0,configurable:!0}),t.prototype.calculateLosses=function(){return this.losses.map(function(e){return e()})},Object.defineProperty(t.prototype,"updates",{get:function(){return this._updates},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"built",{get:function(){return this._built},set:function(e){this._built=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.trainable?this._trainableWeights:[]},set:function(e){this._trainableWeights=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this._nonTrainableWeights:this._trainableWeights.concat(this._nonTrainableWeights)},set:function(e){this._nonTrainableWeights=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateful",{get:function(){return this._stateful},enumerable:!0,configurable:!0}),t.prototype.assertInputCompatibility=function(e){if(e=v.toList(e),null!=this.inputSpec&&0!==this.inputSpec.length){var t=v.toList(this.inputSpec);if(e.length!==t.length)throw new f.ValueError("Layer "+this.name+" expects "+t.length+" inputs, but it received "+e.length+" input tensors. Input received: "+e);for(var n=0;n=0?p[u]:p[p.length+u];if(null!=l&&-1===[l,null].indexOf(c))throw new f.ValueError("Input "+n+" is incompatible with layer "+this.name+": expected axis "+u+" of input shape to have value "+l+" but got shape "+p+".")}}if(null!=i.shape)for(var p=d.intShape(r),h=0;h0&&Array.isArray(x[0])?x.map(function(r,i){return new m.SymbolicTensor(A,r,n,v.toList(e),t,n.name,i)}):new m.SymbolicTensor(A,x,n,v.toList(e),t,n.name),n.addInboundNode(e,p,null,null,w,x,t),null!=n.activityRegularizer)throw new f.NotImplementedError("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return p})},t.prototype.build=function(e){this.built=!0},t.prototype.getWeights=function(){return d.batchGetValue(this.weights)},t.prototype.setWeights=function(e){var t=this.weights;if(t.length!==e.length)throw new f.ValueError('You called setWeights(weights) on layer "'+this.name+'" with a weight list of length '+e.length+", but the layer was expecting "+t.length+" weights. Provided weights: "+e+"...");if(0!==t.length){for(var n=[],r=d.batchGetValue(t),i=0;i1 nodes"),v.assert(0===l,"input layer has >1 tensors"),r.inputLayers.push(s),r.inputLayersNodeIndices.push(u),r.inputLayersTensorIndices.push(l)}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(M=0;M=0;)i.splice(i.indexOf(u),1);E.push(u)}},S=[],C=[],O=0,k=r.outputs;Or?1:0});for(var H=0,K=q;H0)throw new f.ValueError("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];for(var e=[],t=0,n=this.layers;t1)for(var s=0,u=o;s0)){for(var d=[],f=0;f0&&e.apply(v.singletonOrArray(a),i)}(S,d[h]);delete i[S.name]}}for(var m=[],y=[],b=0,w=t.inputLayers;b0)s=!0;else if(a(e)){for(var u in e)if(e.hasOwnProperty(u)){s=!0;break}}else s=!0;if(s)throw new A.ValueError("Error when checking model "+o+" expected no data, but got "+e)}return[]}if(null==e)return t.map(function(e){return null});var l;if(a(e)){e=e,l=[];for(var c=0,p=t;c1)throw new A.ValueError("The model "+o+" expects "+t.length+" Tensor(s), but only received one Tensor. Found: Tensor with shape "+e.shape);l=[e]}for(d=0;d=0&&m!==v)throw new A.ValueError("Error when checking "+o+": expected "+t[d]+" to have shape ["+n[d]+"], but got array with shape ["+f.shape+"].")}}return l}function s(e,t,n){var r=S.unique(e.map(function(e){return e.shape[0]}));r.sort();var i=S.unique(t.map(function(e){return e.shape[0]}));if(i.sort(),r.length>1)throw new A.ValueError("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map(function(e){return e.shape})));if(i.length>1)throw new A.ValueError("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map(function(e){return e.shape})));if(r.length>0&&i.length>0&&!b.util.arraysEqual(r,i))throw new A.ValueError("Input Tensors should have the same number of samples as target Tensors. Found "+r[0]+" input sample(s) and "+i[0]+" target sample(s).")}function u(e,t,n){for(var r=[E.meanSquaredError,E.binaryCrossentropy,E.categoricalCrossentropy],i=0;i=e&&(i=e),n.push([r,i]),r=i;return n}function c(e,t,n){return null==e?[null]:Array.isArray(e)?e.map(function(e){return w.sliceAlongFirstAxis(e,t,n-t)}):w.sliceAlongFirstAxis(e,t,n-t)}function p(e,t){return null==e?null:Array.isArray(e)?e.map(function(e){return p(e,t)}):w.gather(e,"int32"===t.dtype?t:t.toInt())}function h(e,t,n,r,i){void 0===r&&(r=!0),void 0===i&&(i="");var a;if(Array.isArray(e)){if(e.length!==t.length)throw new A.ValueError("Error when checking model "+i+": the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see "+t.length+" Tensor(s), but instead got "+e.length+" Tensors(s).");a=e}else{if(t.length>1)throw new A.ValueError("The model expects "+t.length+" "+i+" Tensors, but only received one Tensor. Found: array with shape "+JSON.stringify(e.shape)+".");a=[e]}if(null!=n)for(var o=0;o=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},m=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}u((r=r.apply(e,t||[])).next())})},v=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(o=a[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(a,n[1])).done)return o;switch(a=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]1&&(t.metricsTensors.push([n,e]),t.metricsNames.push(t.outputNames[e]+"_loss"))}});var p=d(e.metrics,this.outputNames),h=function(e,n,r){t.outputNames.length>1&&(n=t.outputNames[e]+"_"+n),t.metricsNames.push(n),t.metricsTensors.push([r,e])};w.nameScope("metric",function(){for(var e=0;e0&&e[0].shape[0]%r!=0)throw new A.ValueError("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+r+". Found: "+e[0].shape[0]+" sample(s).");return[e,t,null]},t.prototype.fitLoop=function(e,t,n,r,i,a,o,s,u,c,h,d,f,g){return void 0===d&&(d=0),m(this,void 0,void 0,function(){var m,E,_,T,S,O,k=this;return v(this,function(R){switch(R.label){case 0:if(null==r&&(r=32),null==i&&(i=100),null==c&&(c=!0),null==d&&(d=0),m=!1,null!=s&&null!=u&&(m=!0),null!=g&&(m=!0,null==f))throw new A.ValueError("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");if(null!=(E=this.checkNumSamples(t,r,f,"steps_per_epoch"))&&(_=C.range(0,E)),this.history=new x.History,o=null==o?[new x.BaseLogger]:[new x.BaseLogger].concat(o),o=o.concat([this.history]),a>0)throw new A.NotImplementedError("Verbose mode is not implemented yet.");return(T=new x.CallbackList(o)).setModel(this),T.setParams({epochs:i,steps:f,verbose:a,doValidation:m,metrics:h}),[4,T.onTrainBegin()];case 1:R.sent(),S=function(i){var a,o,h,d,g;return v(this,function(S){switch(S.label){case 0:return[4,T.onEpochBegin(i)];case 1:if(S.sent(),a={},null==f)return[3,2];throw new A.NotImplementedError("stepsPerEpoch mode is not implemented yet.");case 2:if("batch"===c)throw new A.NotImplementedError("batch shuffling is not implemneted yet");c&&b.util.shuffle(_),o=b.tensor1d(_),h=l(E,r),d=function(i){var l;return v(this,function(c){switch(c.label){case 0:return l={},[4,T.onBatchBegin(i,l)];case 1:return c.sent(),y.tidy(function(){var c=h[i][0],d=h[i][1],f=w.sliceAlongFirstAxis(o,c,d-c);l.batch=i,l.size=d-c;for(var g=p(t,f),v=e(g),y=0;y1&&(i+="_"+S.count(e.slice(0,n),r)),t.push(i)}return t},t.prototype.makeTestFunction=function(){var e=this;this.testFunction=function(t){return y.tidy(function(){for(var n,r=[],i=t.slice(0,e.inputs.length),a=t.slice(e.inputs.length,e.inputs.length+e.outputs.length),o=[],s=0;s0){if(s=!0,2!==n.validationData.length)throw 3===n.validationData.length?new A.NotImplementedError("validationData including sample weights is not supported yet."):new A.ValueError("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+n.validationData+" is invalid.");u=n.validationData[0],l=n.validationData[1],h=this.standardizeUserData(u,l,!0,r),u=h[0],l=h[1],p=u.concat(l)}else null!=n.validationSplit&&n.validationSplit>0&&n.validationSplit<1?(s=!0,d=Math.floor(a[0].shape[0]*(1-n.validationSplit)),f=a[0].shape[0],u=c(a,d,f),a=c(a,0,d),l=c(o,d,f),o=c(o,0,d),p=u.concat(l)):null!=n.validationSteps&&(s=!0);return g=a.concat(o),this.checkTrainableWeightsConsistency(),m=function(e){var t=[],n=[],r=e.slice(0,T.inputs.length),i=e.slice(T.inputs.length,T.inputs.length+T.outputs.length),a=[],o=T.collectedTrainableWeights.map(function(e){return e.read()});return[T.optimizer.minimize(function(){for(var e=[],o=0;o=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var i=e("@tensorflow/tfjs-core"),a=e("./constraints"),o=e("./engine/topology"),s=e("./engine/training"),u=e("./initializers"),l=e("./layers/advanced_activations"),c=e("./layers/convolutional"),p=e("./layers/convolutional_depthwise"),h=e("./layers/core"),d=e("./layers/embeddings"),f=e("./layers/merge"),g=e("./layers/normalization"),m=e("./layers/padding"),v=e("./layers/pooling"),y=e("./layers/recurrent"),b=e("./layers/wrappers"),w=e("./losses"),x=e("./metrics"),A=e("./models"),E=e("./regularizers"),_=function(){function e(){}return e.model=function(e){return new s.Model(e)},e.sequential=function(e){return new A.Sequential(e)},e.loadModel=function(e){return A.loadModelInternal(e)},e.input=function(e){return o.Input(e)},r([i.doc({heading:"Models",subheading:"Creation",configParamIndices:[0]})],e,"model",null),r([i.doc({heading:"Models",subheading:"Creation",configParamIndices:[0]})],e,"sequential",null),r([i.doc({heading:"Models",subheading:"Loading",useDocsFrom:"loadModelInternal"})],e,"loadModel",null),r([i.doc({heading:"Models",subheading:"Inputs",useDocsFrom:"Input",configParamIndices:[0]})],e,"input",null),e}();n.ModelExports=_;var T=function(){function e(){}return e.inputLayer=function(e){return new o.InputLayer(e)},e.elu=function(e){return new l.ELU(e)},e.leakyReLU=function(e){return new l.LeakyReLU(e)},e.softmax=function(e){return new l.Softmax(e)},e.thresholdedReLU=function(e){return new l.ThresholdedReLU(e)},e.conv1d=function(e){return new c.Conv1D(e)},e.conv2d=function(e){return new c.Conv2D(e)},e.conv2dTranspose=function(e){return new c.Conv2DTranspose(e)},e.separableConv2d=function(e){return new c.SeparableConv2D(e)},e.depthwiseConv2d=function(e){return new p.DepthwiseConv2D(e)},e.activation=function(e){return new h.Activation(e)},e.dense=function(e){return new h.Dense(e)},e.dropout=function(e){return new h.Dropout(e)},e.flatten=function(e){return new h.Flatten(e)},e.repeatVector=function(e){return new h.RepeatVector(e)},e.reshape=function(e){return new h.Reshape(e)},e.embedding=function(e){return new d.Embedding(e)},e.add=function(e){return new f.Add(e)},e.average=function(e){return new f.Average(e)},e.concatenate=function(e){return new f.Concatenate(e)},e.maximum=function(e){return new f.Maximum(e)},e.minimum=function(e){return new f.Minimum(e)},e.multiply=function(e){return new f.Multiply(e)},e.batchNormalization=function(e){return new g.BatchNormalization(e)},e.zeroPadding2d=function(e){return new m.ZeroPadding2D(e)},e.averagePooling1d=function(e){return new v.AveragePooling1D(e)},e.avgPool1d=function(t){return e.averagePooling1d(t)},e.avgPooling1d=function(t){return e.averagePooling1d(t)},e.averagePooling2d=function(e){return new v.AveragePooling2D(e)},e.avgPool2d=function(t){return e.averagePooling2d(t)},e.avgPooling2d=function(t){return e.averagePooling2d(t)},e.globalAveragePooling1d=function(e){return new v.GlobalAveragePooling1D(e)},e.globalAveragePooling2d=function(e){return new v.GlobalAveragePooling2D(e)},e.globalMaxPooling1d=function(e){return new v.GlobalMaxPooling1D(e)},e.globalMaxPooling2d=function(e){return new v.GlobalMaxPooling2D(e)},e.maxPooling1d=function(e){return new v.MaxPooling1D(e)},e.maxPooling2d=function(e){return new v.MaxPooling2D(e)},e.gru=function(e){return new y.GRU(e)},e.gruCell=function(e){return new y.GRUCell(e)},e.lstm=function(e){return new y.LSTM(e)},e.lstmCell=function(e){return new y.LSTMCell(e)},e.simpleRNN=function(e){return new y.SimpleRNN(e)},e.simpleRNNCell=function(e){return new y.SimpleRNNCell(e)},e.rnn=function(e){return new y.RNN(e)},e.stackedRNNCells=function(e){return new y.StackedRNNCells(e)},e.bidirectional=function(e){return new b.Bidirectional(e)},e.timeDistributed=function(e){return new b.TimeDistributed(e)},e.Layer=o.Layer,e.RNNCell=y.RNNCell,e.input=_.input,r([i.doc({heading:"Layers",subheading:"Inputs",namespace:"layers",useDocsFrom:"InputLayer",configParamIndices:[0]})],e,"inputLayer",null),r([i.doc({heading:"Layers",subheading:"Advanced Activation",namespace:"layers",useDocsFrom:"ELU",configParamIndices:[0]})],e,"elu",null),r([i.doc({heading:"Layers",subheading:"Advanced Activation",namespace:"layers",useDocsFrom:"LeakyReLU",configParamIndices:[0]})],e,"leakyReLU",null),r([i.doc({heading:"Layers",subheading:"Advanced Activation",namespace:"layers",useDocsFrom:"Softmax",configParamIndices:[0]})],e,"softmax",null),r([i.doc({heading:"Layers",subheading:"Advanced Activation",namespace:"layers",useDocsFrom:"ThresholdedReLU",configParamIndices:[0]})],e,"thresholdedReLU",null),r([i.doc({heading:"Layers",subheading:"Convolutional",namespace:"layers",useDocsFrom:"Conv1D",configParamIndices:[0]})],e,"conv1d",null),r([i.doc({heading:"Layers",subheading:"Convolutional",namespace:"layers",useDocsFrom:"Conv2D",configParamIndices:[0]})],e,"conv2d",null),r([i.doc({heading:"Layers",subheading:"Convolutional",namespace:"layers",useDocsFrom:"Conv2DTranspose",configParamIndices:[0]})],e,"conv2dTranspose",null),r([i.doc({heading:"Layers",subheading:"Convolutional",namespace:"layers",useDocsFrom:"SeparableConv2D",configParamIndices:[0]})],e,"separableConv2d",null),r([i.doc({heading:"Layers",subheading:"Convolutional",namespace:"layers",useDocsFrom:"DepthwiseConv2D",configParamIndices:[0]})],e,"depthwiseConv2d",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Activation",configParamIndices:[0]})],e,"activation",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Dense",configParamIndices:[0]})],e,"dense",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Dropout",configParamIndices:[0]})],e,"dropout",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Flatten",configParamIndices:[0]})],e,"flatten",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"RepeatVector",configParamIndices:[0]})],e,"repeatVector",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Reshape",configParamIndices:[0]})],e,"reshape",null),r([i.doc({heading:"Layers",subheading:"Basic",namespace:"layers",useDocsFrom:"Embedding",configParamIndices:[0]})],e,"embedding",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Add",configParamIndices:[0]})],e,"add",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Average",configParamIndices:[0]})],e,"average",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Concatenate",configParamIndices:[0]})],e,"concatenate",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Maximum",configParamIndices:[0]})],e,"maximum",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Minimum",configParamIndices:[0]})],e,"minimum",null),r([i.doc({heading:"Layers",subheading:"Merge",namespace:"layers",useDocsFrom:"Multiply",configParamIndices:[0]})],e,"multiply",null),r([i.doc({heading:"Layers",subheading:"Normalization",namespace:"layers",useDocsFrom:"BatchNormalization",configParamIndices:[0]})],e,"batchNormalization",null),r([i.doc({heading:"Layers",subheading:"Padding",namespace:"layers",useDocsFrom:"ZeroPadding2D",configParamIndices:[0]})],e,"zeroPadding2d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"AveragePooling1D",configParamIndices:[0]})],e,"averagePooling1d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"AveragePooling2D",configParamIndices:[0]})],e,"averagePooling2d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"GlobalAveragePooling1D",configParamIndices:[0]})],e,"globalAveragePooling1d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"GlobalAveragePooling2D",configParamIndices:[0]})],e,"globalAveragePooling2d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"GlobalMaxPooling1D",configParamIndices:[0]})],e,"globalMaxPooling1d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"GlobalMaxPooling2D",configParamIndices:[0]})],e,"globalMaxPooling2d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"MaxPooling1D",configParamIndices:[0]})],e,"maxPooling1d",null),r([i.doc({heading:"Layers",subheading:"Pooling",namespace:"layers",useDocsFrom:"MaxPooling2D",configParamIndices:[0]})],e,"maxPooling2d",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"GRU",configParamIndices:[0]})],e,"gru",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"GRUCell",configParamIndices:[0]})],e,"gruCell",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"LSTM",configParamIndices:[0]})],e,"lstm",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"LSTMCell",configParamIndices:[0]})],e,"lstmCell",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"SimpleRNN",configParamIndices:[0]})],e,"simpleRNN",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"SimpleRNNCell",configParamIndices:[0]})],e,"simpleRNNCell",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"RNN",configParamIndices:[0]})],e,"rnn",null),r([i.doc({heading:"Layers",subheading:"Recurrent",namespace:"layers",useDocsFrom:"RNN",configParamIndices:[0]})],e,"stackedRNNCells",null),r([i.doc({heading:"Layers",subheading:"Wrapper",namespace:"layers",useDocsFrom:"Bidirectional",configParamIndices:[0]})],e,"bidirectional",null),r([i.doc({heading:"Layers",subheading:"Wrapper",namespace:"layers",useDocsFrom:"TimeDistributed",configParamIndices:[0]})],e,"timeDistributed",null),e}();n.LayerExports=T;var S=function(){function e(){}return e.maxNorm=function(e){return new a.MaxNorm(e)},e.unitNorm=function(e){return new a.UnitNorm(e)},e.nonNeg=function(){return new a.NonNeg},e.minMaxNorm=function(e){return new a.MinMaxNorm(e)},r([i.doc({heading:"Constraints",namespace:"constraints",useDocsFrom:"MaxNorm",configParamIndices:[0]})],e,"maxNorm",null),r([i.doc({heading:"Constraints",namespace:"constraints",useDocsFrom:"UnitNorm",configParamIndices:[0]})],e,"unitNorm",null),r([i.doc({heading:"Constraints",namespace:"constraints",useDocsFrom:"NonNeg"})],e,"nonNeg",null),r([i.doc({heading:"Constraints",namespace:"constraints",useDocsFrom:"MinMaxNormConfig",configParamIndices:[0]})],e,"minMaxNorm",null),e}();n.ConstraintExports=S;var C=function(){function e(){}return e.zeros=function(){return new u.Zeros},e.ones=function(){return new u.Ones},e.constant=function(e){return new u.Constant(e)},e.randomUniform=function(e){return new u.RandomUniform(e)},e.randomNormal=function(e){return new u.RandomNormal(e)},e.truncatedNormal=function(e){return new u.TruncatedNormal(e)},e.identity=function(e){return new u.Identity(e)},e.varianceScaling=function(e){return new u.VarianceScaling(e)},e.glorotUniform=function(e){return new u.GlorotUniform(e)},e.glorotNormal=function(e){return new u.GlorotNormal(e)},e.heNormal=function(e){return new u.HeNormal(e)},e.leCunNormal=function(e){return new u.LeCunNormal(e)},e.orthogonal=function(e){return new u.Orthogonal(e)},r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"Zeros"})],e,"zeros",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"Ones"})],e,"ones",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"Constant",configParamIndices:[0]})],e,"constant",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"RandomUniform",configParamIndices:[0]})],e,"randomUniform",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"RandomNormal",configParamIndices:[0]})],e,"randomNormal",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"TruncatedNormal",configParamIndices:[0]})],e,"truncatedNormal",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"Identity",configParamIndices:[0]})],e,"identity",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"VarianceScaling",configParamIndices:[0]})],e,"varianceScaling",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"GlorotUniform",configParamIndices:[0]})],e,"glorotUniform",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"GlorotNormal",configParamIndices:[0]})],e,"glorotNormal",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"HeNormal",configParamIndices:[0]})],e,"heNormal",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"LeCunNormal",configParamIndices:[0]})],e,"leCunNormal",null),r([i.doc({heading:"Initializers",namespace:"initializers",useDocsFrom:"Orthogonal",configParamIndices:[0]})],e,"orthogonal",null),e}();n.InitializerExports=C;var O=function(){function e(){}return e.binaryAccuracy=function(e,t){return x.binaryAccuracy(e,t)},e.binaryCrossentropy=function(e,t){return x.binaryCrossentropy(e,t)},e.categoricalAccuracy=function(e,t){return x.categoricalAccuracy(e,t)},e.categoricalCrossentropy=function(e,t){return w.categoricalCrossentropy(e,t)},e.cosineProximity=function(e,t){return w.cosineProximity(e,t)},e.prototype.meanAbsoluteError=function(e,t){return w.meanAbsoluteError(e,t)},e.prototype.meanAbsolutePercentageError=function(e,t){return w.meanAbsolutePercentageError(e,t)},e.prototype.MAPE=function(e,t){return w.meanAbsolutePercentageError(e,t)},e.prototype.mape=function(e,t){return w.meanAbsolutePercentageError(e,t)},e.meanSquaredError=function(e,t){return w.meanSquaredError(e,t)},e.MSE=function(e,t){return w.meanSquaredError(e,t)},e.mse=function(e,t){return w.meanSquaredError(e,t)},r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"meanAbsoluteError"})],e.prototype,"meanAbsoluteError",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"meanAbsolutePercentageError"})],e.prototype,"meanAbsolutePercentageError",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"binaryAccuracy"})],e,"binaryAccuracy",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"binaryCrossentropy"})],e,"binaryCrossentropy",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"categoricalAccuracy"})],e,"categoricalAccuracy",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"categoricalCrossentropy"})],e,"categoricalCrossentropy",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"cosineProximity"})],e,"cosineProximity",null),r([i.doc({heading:"Metrics",namespace:"metrics",useDocsFrom:"meanSquaredError"})],e,"meanSquaredError",null),e}();n.MetricExports=O;var k=function(){function e(){}return e.l1l2=function(e){return new E.L1L2(e)},e.l1=function(e){return E.l1(e)},e.l2=function(e){return E.l2(e)},r([i.doc({heading:"Regularizers",namespace:"regularizers",useDocsFrom:"L1L2"})],e,"l1l2",null),r([i.doc({heading:"Regularizers",namespace:"regularizers",useDocsFrom:"L1L2"})],e,"l1",null),r([i.doc({heading:"Regularizers",namespace:"regularizers",useDocsFrom:"L1L2"})],e,"l2",null),e}();n.RegularizerExports=k},{"./constraints":103,"./engine/topology":105,"./engine/training":106,"./initializers":110,"./layers/advanced_activations":111,"./layers/convolutional":112,"./layers/convolutional_depthwise":113,"./layers/core":114,"./layers/embeddings":115,"./layers/merge":116,"./layers/normalization":117,"./layers/padding":118,"./layers/pooling":119,"./layers/recurrent":120,"./layers/wrappers":122,"./losses":123,"./metrics":124,"./models":125,"./regularizers":127,"@tensorflow/tfjs-core":8}],109:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./backend/tfjs_backend");n.backend=r;var i=e("./exports"),a=e("./callbacks");n.Callback=a.Callback,n.CallbackList=a.CallbackList,n.CustomCallback=a.CustomCallback;var o=e("./engine/training");n.Model=o.Model;var s=e("./layers/recurrent");n.RNN=s.RNN;var u=e("./models");n.Sequential=u.Sequential;var l=e("./types");n.SymbolicTensor=l.SymbolicTensor;var c=e("./version");n.version_layers=c.version,n.model=i.ModelExports.model,n.sequential=i.ModelExports.sequential,n.loadModel=i.ModelExports.loadModel,n.input=i.ModelExports.input,n.layers=i.LayerExports,n.constraints=i.ConstraintExports,n.initializers=i.InitializerExports,n.metrics=i.MetricExports,n.regularizers=i.RegularizerExports},{"./backend/tfjs_backend":100,"./callbacks":101,"./engine/training":106,"./exports":108,"./layers/recurrent":120,"./models":125,"./types":128,"./version":133}],110:[function(e,t,n){"use strict";function r(e){if(null!=e&&n.VALID_FAN_MODE_VALUES.indexOf(e)<0)throw new h.ValueError(e+" is not a valid FanMode. Valid values as "+n.VALID_FAN_MODE_VALUES)}function i(e){if(null!=e&&n.VALID_DISTRIBUTION_VALUES.indexOf(e)<0)throw new h.ValueError(e+" is not a valid Distribution. Valid values as "+n.VALID_DISTRIBUTION_VALUES)}function a(e,t){void 0===t&&(t="channelsLast");var n,r;if(p.checkDataFormat(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){i=g.arrayProd(e,2);n=e[1]*i,r=e[0]*i}else if("channelsLast"===t){var i=g.arrayProd(e,0,e.length-2);n=e[e.length-2]*i,r=e[e.length-1]*i}}else{var a=g.arrayProd(e);n=Math.sqrt(a),r=Math.sqrt(a)}return[n,r]}function o(e,t){return void 0===t&&(t={}),f.deserializeKerasObject(e,f.ClassNameMap.getMap().pythonClassNameMap,t,"initializer")}var s=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var l=e("@tensorflow/tfjs-core"),c=e("./backend/tfjs_backend"),p=e("./common"),h=e("./errors"),d=e("./types"),f=e("./utils/generic_utils"),g=e("./utils/math_utils");f.SerializableEnumRegistry.register("mode",{fan_in:"fanIn",fan_out:"fanOut",fan_avg:"fanAvg"}),n.VALID_FAN_MODE_VALUES=["fanIn","fanOut","fanAvg",void 0,null],n.checkFanMode=r,f.SerializableEnumRegistry.register("distribution",{normal:"normal",uniform:"uniform"}),n.VALID_DISTRIBUTION_VALUES=["normal","uniform",void 0,null],n.checkDistribution=i;var m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.fromConfig=function(e,t){return new e(t)},t.prototype.fromConfigUsesCustomObjects=function(){return!1},t.prototype.getConfig=function(){return{}},t=u([l.doc({heading:"Initializers",subheading:"Classes",namespace:"initializers"})],t)}(d.Serializable);n.Initializer=m;var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.getClassName=function(){return"Zeros"},t.prototype.apply=function(e,t){return c.zeros(e,t)},t}(m);n.Zeros=v,f.ClassNameMap.register("Zeros",v);var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.getClassName=function(){return"Ones"},t.prototype.apply=function(e,t){return c.ones(e,t)},t}(m);n.Ones=y,f.ClassNameMap.register("Ones",y);var b=function(e){function t(t){var n=e.call(this)||this;return n.value=t.value,n}return s(t,e),t.prototype.apply=function(e,t){return c.scalarTimesArray(l.scalar(this.value),c.ones(e,t))},t.prototype.getClassName=function(){return"Constant"},t.prototype.getConfig=function(){return{value:this.value}},t}(m);n.Constant=b,f.ClassNameMap.register("Constant",b);var w=function(e){function t(t){var n=e.call(this)||this;return n.DEFAULT_MINVAL=-.05,n.DEFAULT_MAXVAL=.05,n.minval=t.minval||n.DEFAULT_MINVAL,n.maxval=t.maxval||n.DEFAULT_MAXVAL,n.seed=t.seed,n}return s(t,e),t.prototype.apply=function(e,t){return c.randomUniform(e,this.minval,this.maxval,t,this.seed)},t.prototype.getClassName=function(){return"RandomUniform"},t.prototype.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},t}(m);n.RandomUniform=w,f.ClassNameMap.register("RandomUniform",w);var x=function(e){function t(t){var n=e.call(this)||this;return n.DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}return s(t,e),t.prototype.apply=function(e,t){return c.randomNormal(e,this.mean,this.stddev,t,this.seed)},t.prototype.getClassName=function(){return"RandomNormal"},t.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(m);n.RandomNormal=x,f.ClassNameMap.register("RandomNormal",x);var A=function(e){function t(t){var n=e.call(this)||this;return n.DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}return s(t,e),t.prototype.apply=function(e,t){return c.truncatedNormal(e,this.mean,this.stddev,t,this.seed)},t.prototype.getClassName=function(){return"TruncatedNormal"},t.prototype.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(m);n.TruncatedNormal=A,f.ClassNameMap.register("TruncatedNormal",A);var E=function(e){function t(t){var n=e.call(this)||this;return n.gain=null!=t.gain?l.scalar(t.gain):c.getScalar(1),n}return s(t,e),t.prototype.apply=function(e,t){if(2!==e.length||e[0]!==e[1])throw new h.ValueError("Identity matrix initializer can only be used for 2D square matrices.");return c.scalarTimesArray(this.gain,c.eye(e[0]))},t.prototype.getClassName=function(){return"Identity"},t.prototype.getConfig=function(){return{gain:this.gain.get()}},t}(m);n.Identity=E,f.ClassNameMap.register("Identity",E);var _=function(e){function t(t){var n=e.call(this)||this;if(t.scale<0)throw new h.ValueError("scale must be a positive float. Got: "+t.scale);return n.scale=null==t.scale?1:t.scale,n.mode=t.mode,r(n.mode),n.distribution=t.distribution,i(n.distribution),n.seed=t.seed,n}return s(t,e),t.prototype.apply=function(e,t){var n=a(e),r=n[0],i=n[1],o=this.scale;if("fanIn"===this.mode?o/=Math.max(1,r):"fanOut"===this.mode?o/=Math.max(1,i):o/=Math.max(1,(r+i)/2),"normal"===this.distribution){var s=Math.sqrt(o);return c.truncatedNormal(e,0,s,t,this.seed)}var u=Math.sqrt(3*o);return c.randomUniform(e,-u,u,t,this.seed)},t.prototype.getClassName=function(){return"VarianceScaling"},t.prototype.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},t}(m);n.VarianceScaling=_,f.ClassNameMap.register("VarianceScaling",_);var T=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:t.seed})||this}return s(t,e),t}(_);n.GlorotUniform=T,f.ClassNameMap.register("GlorotUniform",T);var S=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:t.seed})||this}return s(t,e),t}(_);n.GlorotNormal=S,f.ClassNameMap.register("GlorotNormal",S);var C=function(e){function t(t){return e.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:t.seed})||this}return s(t,e),t}(_);n.HeNormal=C,f.ClassNameMap.register("HeNormal",C);var O=function(e){function t(t){return e.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:t.seed})||this}return s(t,e),t}(_);n.LeCunNormal=O,f.ClassNameMap.register("LeCunNormal",O);var k=function(e){function t(t){var n=e.call(this)||this;if(n.DEFAULT_GAIN=1,n.gain=null==t.gain?n.DEFAULT_GAIN:t.gain,n.seed=t.seed,null!=n.seed)throw new h.NotImplementedError("Random seed is not implemented for Orthogonal Initializer yet.");return n}return s(t,e),t.prototype.apply=function(e,t){if(2!==e.length)throw new h.NotImplementedError("The Orthogonal Initializer does not support non-2D shapes yet.");var n=e[0]>=e[1]?e:[e[1],e[0]],r=c.randomNormal(n,0,1,d.DType.float32),i=c.qr(r)[0];return i.shape[1]>n[1]&&(i=i.slice([0,0],n)),e[0]1)throw new s.ValueError("Can not merge tensors with different batch sizes. Got tensors with shapes: "+JSON.stringify(e)+".");for(var i=null==e[0]?null:e[0].slice(1),a=1;a1){A=l.range(1,c).concat([0]);n.push(a.permuteDimensions(u,A)),h=!0}else n.push(u)}var b=this.mergeFunction(n),w=a.ndim(b);if(h)if(null==w){var x=a.shape(b),v=[m=x[x.length-1]].concat(x.slice(0,x.length-1));b=a.reshape(a.permuteDimensions(a.reshape(b,[-1,m]),[1,0]),v)}else if(w>1){var A=[w-1].concat(l.range(0,w-1));b=a.permuteDimensions(b,A)}return b}return this.mergeFunction(e)},t.prototype.computeOutputShape=function(e){var t;t=null==(e=e)[0]?null:e[0].slice(1);for(var n=1;n1)throw new s.ValueError("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}},t.prototype.mergeFunction=function(e){return a.concatenate(e,this.axis)},t.prototype.computeOutputShape=function(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new s.ValueError("A `Concatenate` layer should be called on a list of inputs.");for(var t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis,i=0,a=t.slice(1);i=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new u.ValueError("Axis "+t+" of input tensor should have a defined dimension but the layer received an input with shape "+JSON.stringify(e)+".");this.inputSpec=[new s.InputSpec({ndim:e.length,axes:(i={},i[t]=n,i)})];var r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0;var i},t.prototype.call=function(e,t){var n=this;return i.tidy(function(){var r=null!=t.training&&t.training,o=p.getExactlyOneTensor(e),s=a.shape(o),u=s.length,l=h.range(0,u),c=n.axis>=0?n.axis:n.axis+u;l.splice(c,1);var d=p.pyListRepeat(1,u);d[c]=s[c];var f=l.slice();f.sort();var g=!i.util.arraysEqual(f,h.range(0,u).slice(0,u-1));if(!r)return function(){if(g){var e=a.reshape(n.movingMean.read(),d),t=a.reshape(n.movingVariance.read(),d),r=n.center?a.reshape(n.beta.read(),d):null,i=n.scale?a.reshape(n.gamma.read(),d):null;return a.batchNormalization(o,e,t,r,i,n.epsilon)}return a.batchNormalization(o,n.movingMean.read(),n.movingVariance.read(),null==n.beta?null:n.beta.read(),null==n.gamma?null:n.gamma.read(),n.epsilon)}();var m=a.normalizeBatchInTraining(o,n.gamma.read(),n.beta.read(),l,n.epsilon),v=m[0],y=m[1],b=m[2],w=h.arrayProd(l.map(function(e){return o.shape[e]})),x=b.mul(a.getScalar(w/(w-(1+n.epsilon))));return function(){n.stepCount++;var e=i.movingAverage(n.movingMean.read(),y,n.momentum,n.stepCount);n.movingMean.write(e);var t=i.movingAverage(n.movingVariance.read(),x,n.momentum,n.stepCount);n.movingVariance.write(t)}(),v})},t.prototype.getClassName=function(){return"BatchNormalization"},t.prototype.getConfig=function(){var t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:l.serializeInitializer(this.betaInitializer),gammaInitializer:l.serializeInitializer(this.gammaInitializer),movingMeanInitializer:l.serializeInitializer(this.movingMeanInitializer),movingVarianceInitializer:l.serializeInitializer(this.movingVarianceInitializer),betaRegularizer:c.serializeRegularizer(this.betaRegularizer),gammaRegularizer:c.serializeRegularizer(this.gammaRegularizer),betaConstraint:o.serializeConstraint(this.betaConstraint),gammaConstraint:o.serializeConstraint(this.gammaConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(s.Layer);n.BatchNormalization=d,p.ClassNameMap.register("BatchNormalization",d)},{"../backend/tfjs_backend":100,"../constraints":103,"../engine/topology":105,"../errors":107,"../initializers":110,"../regularizers":127,"../utils/generic_utils":130,"../utils/math_utils":131,"@tensorflow/tfjs-core":8}],118:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../backend/common"),a=e("../backend/tfjs_backend"),o=e("../engine/topology"),s=e("../errors"),u=e("../utils/generic_utils"),l=function(e){function t(t){var n=this;if(null==t&&(t={}),n=e.call(this,t)||this,n.dataFormat=null==t.dataFormat?i.imageDataFormat():t.dataFormat,null==t.padding)n.padding=[[1,1],[1,1]];else if("number"==typeof t.padding)n.padding=[[t.padding,t.padding],[t.padding,t.padding]];else{if(t.padding=t.padding,2!==t.padding.length)throw new s.ValueError("ZeroPadding2D expects padding to be a length-2 array, but received a length-"+t.padding.length+" array.");var r=void 0,a=void 0;if("number"==typeof t.padding[0])r=[t.padding[0],t.padding[0]],a=[t.padding[1],t.padding[1]];else{if(t.padding=t.padding,2!==t.padding[0].length)throw new s.ValueError("ZeroPadding2D expects height padding to be a length-2 array, but received a length-"+t.padding[0].length+" array.");if(r=t.padding[0],2!==t.padding[1].length)throw new s.ValueError("ZeroPadding2D expects width padding to be a length-2 array, but received a length-"+t.padding[1].length+" array.");a=t.padding[1]}n.padding=[r,a]}return n.inputSpec=[new o.InputSpec({ndim:4})],n}return r(t,e),t.prototype.computeOutputShape=function(e){e=u.getExactlyOneShape(e);var t,n;return"channelsFirst"===this.dataFormat?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])},t.prototype.call=function(e,t){return a.spatial2dPadding(u.getExactlyOneTensor(e),this.padding,this.dataFormat)},t.prototype.getClassName=function(){return"ZeroPadding2D"},t.prototype.getConfig=function(){var t={padding:this.padding,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(o.Layer);n.ZeroPadding2D=l,u.ClassNameMap.register("ZeroPadding2D",l)},{"../backend/common":99,"../backend/tfjs_backend":100,"../engine/topology":105,"../errors":107,"../utils/generic_utils":130}],119:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var i=e("../backend/tfjs_backend"),a=e("../common"),o=e("../engine/topology"),s=e("../engine/topology"),u=e("../errors"),l=e("../utils/conv_utils"),c=e("../utils/generic_utils"),p=function(e){function t(t){var n=this;return null==t.poolSize&&(t.poolSize=2),n=e.call(this,t)||this,n.poolSize=[t.poolSize],n.strides=null==t.strides?n.poolSize:[t.strides],n.padding=null==t.padding?"valid":t.padding,a.checkPaddingMode(n.padding),n.inputSpec=[new o.InputSpec({ndim:3})],n}return r(t,e),t.prototype.computeOutputShape=function(e){return e=c.getExactlyOneShape(e),length=l.convOutputLength(e[1],this.poolSize[0],this.padding,this.strides[0]),[e[0],length,e[2]]},t.prototype.call=function(e,t){this.invokeCallHook(e,t),e=i.expandDims(c.getExactlyOneTensor(e),2);var n=this.poolingFunction(c.getExactlyOneTensor(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return i.squeeze(n,2)},t.prototype.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(s.Layer);n.Pooling1D=p;var h=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"MaxPooling1D"},t.prototype.poolingFunction=function(e,t,n,r,o){return a.checkDataFormat(o),a.checkPaddingMode(r),i.pool2d(e,t,n,r,o,"max")},t}(p);n.MaxPooling1D=h,c.ClassNameMap.register("MaxPooling1D",h);var d=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"AveragePooling1D"},t.prototype.poolingFunction=function(e,t,n,r,o){return a.checkDataFormat(o),a.checkPaddingMode(r),i.pool2d(e,t,n,r,o,"avg")},t}(p);n.AveragePooling1D=d,c.ClassNameMap.register("AveragePooling1D",d);var f=function(e){function t(t){var n=this;return null==t.poolSize&&(t.poolSize=[2,2]),n=e.call(this,t)||this,n.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],n.strides=null==t.strides?n.poolSize:t.strides,n.padding=null==t.padding?"valid":t.padding,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,a.checkDataFormat(n.dataFormat),a.checkPaddingMode(n.padding),n.inputSpec=[new o.InputSpec({ndim:4})],n}return r(t,e),t.prototype.computeOutputShape=function(e){e=c.getExactlyOneShape(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=l.convOutputLength(t,this.poolSize[0],this.padding,this.strides[0]),n=l.convOutputLength(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]},t.prototype.call=function(e,t){return this.invokeCallHook(e,t),this.poolingFunction(c.getExactlyOneTensor(e),this.poolSize,this.strides,this.padding,this.dataFormat)},t.prototype.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(s.Layer);n.Pooling2D=f;var g=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"MaxPooling2D"},t.prototype.poolingFunction=function(e,t,n,r,o){return a.checkDataFormat(o),a.checkPaddingMode(r),i.pool2d(e,t,n,r,o,"max")},t}(f);n.MaxPooling2D=g,c.ClassNameMap.register("MaxPooling2D",g);var m=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"AveragePooling2D"},t.prototype.poolingFunction=function(e,t,n,r,o){return a.checkDataFormat(o),a.checkPaddingMode(r),i.pool2d(e,t,n,r,o,"avg")},t}(f);n.AveragePooling2D=m,c.ClassNameMap.register("AveragePooling2D",m);var v=function(e){function t(t){var n=e.call(this,t)||this;return n.inputSpec=[new o.InputSpec({ndim:3})],n}return r(t,e),t.prototype.computeOutputShape=function(e){return[e[0],e[2]]},t.prototype.call=function(e,t){throw new u.NotImplementedError},t}(s.Layer);n.GlobalPooling1D=v;var y=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"GlobalAveragePooling1D"},t.prototype.call=function(e,t){var n=c.getExactlyOneTensor(e);return i.mean(n,1)},t}(v);n.GlobalAveragePooling1D=y,c.ClassNameMap.register("GlobalAveragePooling1D",y);var b=function(e){function t(t){return e.call(this,t)||this}return r(t,e),t.prototype.getClassName=function(){return"GlobalMaxPooling1D"},t.prototype.call=function(e,t){var n=c.getExactlyOneTensor(e);return i.max(n,1)},t}(v);n.GlobalMaxPooling1D=b,c.ClassNameMap.register("GlobalMaxPooling1D",b);var w=function(e){function t(t){var n=e.call(this,t)||this;return n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,a.checkDataFormat(n.dataFormat),n.inputSpec=[new o.InputSpec({ndim:4})],n}return r(t,e),t.prototype.computeOutputShape=function(e){return e=e,"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]},t.prototype.call=function(e,t){throw new u.NotImplementedError},t.prototype.getConfig=function(){var t={dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(s.Layer);n.GlobalPooling2D=w;var x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.call=function(e,t){var n=c.getExactlyOneTensor(e);return"channelsLast"===this.dataFormat?i.mean(n,[1,2]):i.mean(n,[2,3])},t.prototype.getClassName=function(){return"GlobalAveragePooling2D"},t}(w);n.GlobalAveragePooling2D=x,c.ClassNameMap.register("GlobalAveragePooling2D",x);var A=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.call=function(e,t){var n=c.getExactlyOneTensor(e);return"channelsLast"===this.dataFormat?i.max(n,[1,2]):i.max(n,[2,3])},t.prototype.getClassName=function(){return"GlobalMaxPooling2D"},t}(w);n.GlobalMaxPooling2D=A,c.ClassNameMap.register("GlobalMaxPooling2D",A)},{"../backend/tfjs_backend":100,"../common":102,"../engine/topology":105,"../errors":107,"../utils/conv_utils":129,"../utils/generic_utils":130}],120:[function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),i=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var a=e("@tensorflow/tfjs-core"),o=e("../activations"),s=e("../backend/tfjs_backend"),u=e("../constraints"),l=e("../engine/topology"),c=e("../engine/topology"),p=e("../errors"),h=e("../initializers"),d=e("../regularizers"),f=e("../types"),g=e("../utils/generic_utils"),m=e("../utils/math_utils"),v=e("./serialization"),y=function(e){function t(t){var n,r=e.call(this,t)||this;if(null==t.cell)throw new p.ValueError("cell property is missing for the constructor of RNN.");if(null==(n=Array.isArray(t.cell)?new S({cells:t.cell}):t.cell).stateSize)throw new p.ValueError("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return r.cell=n,r.returnSequences=null!=t.returnSequences&&t.returnSequences,r.returnState=null!=t.returnState&&t.returnState,r.goBackwards=null!=t.goBackwards&&t.goBackwards,r._stateful=null!=t.stateful&&t.stateful,r.unroll=null!=t.unroll&&t.unroll,r.supportsMasking=!0,r.inputSpec=[new l.InputSpec({ndim:3})],r.stateSpec=null,r.states=null,r.numConstants=null,r}return r(t,e),t.prototype.getStates=function(){if(null==this.states){var e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return m.range(0,e).map(function(e){return null})}return this.states},t.prototype.setStates=function(e){this.states=e},t.prototype.computeOutputShape=function(e){g.isArrayOfShapes(e)&&(e=e[0]),e=e;var t=this.cell.stateSize;Array.isArray(t)||(t=[t]);var n,r=t[0];if(n=this.returnSequences?[e[0],e[1],r]:[e[0],r],this.returnState){for(var i=[],a=0,o=t;a1&&(t=e.slice(1,e.length)),e=e[0]}return t=r(t),n=r(n),{inputs:e,initialState:t,constants:n}},t.prototype.apply=function(t,n){var r=null==n?null:n.initialState,i=null==n?null:n.constants;null==n&&(n={});var a=this.standardizeArgs(t,r,i);t=a.inputs,r=a.initialState,i=a.constants;var o=[],s=[];if(null!=r){n.initialState=r,o=o.concat(r),this.stateSpec=[];for(var u=0,c=r;u1?s.tile(t,[1,e]):t}):this.cell.stateSize>1?[s.tile(t,[1,this.cell.stateSize])]:[t]},Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.trainable?this.cell.trainableWeights:[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"RNN"},t.prototype.getConfig=function(){var t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(t.numConstants=this.numConstants);var n=this.cell.getConfig();t.cell={className:this.cell.getClassName(),config:n};var r=e.prototype.getConfig.call(this);return Object.assign(t,r),t},t}(c.Layer);n.RNN=y,g.ClassNameMap.register("RNN",y);var b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t=i([a.doc({heading:"Layers",subheading:"Classes"})],t)}(c.Layer);n.RNNCell=b;var w=function(e){function t(t){var n=e.call(this,t)||this;return n.DEFAULT_ACTIVATION="tanh",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,n.activation=o.getActivation(null==t.activation?n.DEFAULT_ACTIVATION:t.activation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=h.getInitializer(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=h.getInitializer(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=h.getInitializer(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=d.getRegularizer(t.kernelRegularizer),n.recurrentRegularizer=d.getRegularizer(t.recurrentRegularizer),n.biasRegularizer=d.getRegularizer(t.biasRegularizer),n.kernelConstraint=u.getConstraint(t.kernelConstraint),n.recurrentConstraint=u.getConstraint(t.recurrentConstraint),n.biasConstraint=u.getConstraint(t.biasConstraint),n.dropout=m.min([1,m.max([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=m.min([1,m.max([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.stateSize=n.units,n}return r(t,e),t.prototype.build=function(e){e=g.getExactlyOneShape(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},t.prototype.call=function(e,t){if(2!==(e=e).length)throw new p.ValueError("SimpleRNNCell expects 2 input Tensors, got "+e.length+".");var n=e[1];if(e=e[0],0!==this.dropout||0!==this.recurrentDropout)throw new p.NotImplementedError("Dropout is not implemented for SimpleRNNCell yet");var r=s.dot(e,this.kernel.read());null!=this.bias&&(r=s.biasAdd(r,this.bias.read()));var i=s.add(r,s.dot(n,this.recurrentKernel.read()));return null!=this.activation&&(i=this.activation(i)),[i,i]},t.prototype.getClassName=function(){return"SimpleRNNCell"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(b);n.SimpleRNNCell=w,g.ClassNameMap.register("SimpleRNNCell",w);var x=function(e){function t(t){return t.cell=new w(t),e.call(this,t)||this}return r(t,e),t.prototype.call=function(t,n){var r=null==n?null:n.mask,i=null==n?null:n.training,a=null==n?null:n.initialState;return e.prototype.call.call(this,t,{mask:r,training:i,initialState:a})},Object.defineProperty(t.prototype,"units",{get:function(){return this.cell.units},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"activation",{get:function(){return this.cell.activation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBias",{get:function(){return this.cell.useBias},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelInitializer",{get:function(){return this.cell.kernelInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentInitializer",{get:function(){return this.cell.recurrentInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasInitializer",{get:function(){return this.cell.biasInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelRegularizer",{get:function(){return this.cell.kernelRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentRegularizer",{get:function(){return this.cell.recurrentRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasRegularizer",{get:function(){return this.cell.biasRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelConstraint",{get:function(){return this.cell.kernelConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentConstraint",{get:function(){return this.cell.recurrentConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasConstraint",{get:function(){return this.cell.biasConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropout",{get:function(){return this.cell.dropout},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentDropout",{get:function(){return this.cell.recurrentDropout},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"SimpleRNN"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(y);n.SimpleRNN=x,g.ClassNameMap.register("SimpleRNN",x);var A=function(e){function t(t){var n=e.call(this,t)||this;return n.DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,n.activation=o.getActivation(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=o.getActivation(void 0===t.activation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=h.getInitializer(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=h.getInitializer(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=h.getInitializer(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=d.getRegularizer(t.kernelRegularizer),n.recurrentRegularizer=d.getRegularizer(t.recurrentRegularizer),n.biasRegularizer=d.getRegularizer(t.biasRegularizer),n.kernelConstraint=u.getConstraint(t.kernelConstraint),n.recurrentConstraint=u.getConstraint(t.recurrentConstraint),n.biasConstraint=u.getConstraint(t.biasConstraint),n.dropout=m.min([1,m.max([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=m.min([1,m.max([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.implementation=t.implementation,n.stateSize=n.units,n}return r(t,e),t.prototype.build=function(e){var t=(e=g.getExactlyOneShape(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},t.prototype.call=function(e,t){if(0!==this.dropout||0!==this.recurrentDropout)throw new p.NotImplementedError("Dropout is not implemented for GRUCell yet");if(2!==(e=e).length)throw new p.ValueError("GRUCell expects 2 input Tensors (inputs, h, c), got "+e.length+".");var n=e[1];e=e[0];var r,i,a;if(1===this.implementation){var o=s.sliceAlongLastAxis(this.kernel.read(),0,this.units),u=s.sliceAlongLastAxis(this.kernel.read(),this.units,this.units),l=s.sliceAlongLastAxis(this.kernel.read(),2*this.units,this.units),c=s.sliceAlongLastAxis(this.recurrentKernel.read(),0,this.units),h=s.sliceAlongLastAxis(this.recurrentKernel.read(),this.units,this.units),d=s.sliceAlongLastAxis(this.recurrentKernel.read(),2*this.units,this.units),f=e,g=e,m=e,v=s.dot(f,o),y=s.dot(g,u),b=s.dot(m,l);if(this.useBias){var w=s.sliceAlongFirstAxis(this.bias.read(),0,this.units),x=s.sliceAlongFirstAxis(this.bias.read(),this.units,this.units),A=s.sliceAlongFirstAxis(this.bias.read(),2*this.units,this.units);v=s.biasAdd(v,w),y=s.biasAdd(y,x),b=s.biasAdd(b,A)}var E=n,_=n,T=n;r=this.recurrentActivation(s.add(v,s.dot(E,c))),i=this.recurrentActivation(s.add(y,s.dot(_,h))),a=this.activation(s.add(b,s.dot(s.multiply(i,T),d)))}else{var S=s.dot(e,this.kernel.read());this.useBias&&(S=s.biasAdd(S,this.bias.read()));var C=s.dot(n,s.sliceAlongLastAxis(this.recurrentKernel.read(),0,2*this.units)),v=s.sliceAlongLastAxis(S,0,this.units),y=s.sliceAlongLastAxis(S,this.units,this.units),O=s.sliceAlongLastAxis(C,0,this.units),k=s.sliceAlongLastAxis(C,this.units,this.units);r=this.recurrentActivation(s.add(v,O)),i=this.recurrentActivation(s.add(y,k));var b=s.sliceAlongLastAxis(S,2*this.units,this.units),R=s.dot(s.multiply(i,n),s.sliceAlongLastAxis(this.recurrentKernel.read(),2*this.units,this.units));a=this.activation(s.add(b,R))}var N=s.add(s.multiply(r,n),s.multiply(s.scalarPlusArray(s.getScalar(1),s.neg(r)),a));return[N,N]},t.prototype.getClassName=function(){return"GRUCell"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(b);n.GRUCell=A,g.ClassNameMap.register("GRUCell",A);var E=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new A(t),e.call(this,t)||this}return r(t,e),t.prototype.call=function(t,n){var r=null==n?null:n.mask,i=null==n?null:n.training,a=null==n?null:n.initialState;return e.prototype.call.call(this,t,{mask:r,training:i,initialState:a})},Object.defineProperty(t.prototype,"units",{get:function(){return this.cell.units},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"activation",{get:function(){return this.cell.activation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBias",{get:function(){return this.cell.useBias},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelInitializer",{get:function(){return this.cell.kernelInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentInitializer",{get:function(){return this.cell.recurrentInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasInitializer",{get:function(){return this.cell.biasInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelRegularizer",{get:function(){return this.cell.kernelRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentRegularizer",{get:function(){return this.cell.recurrentRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasRegularizer",{get:function(){return this.cell.biasRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelConstraint",{get:function(){return this.cell.kernelConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentConstraint",{get:function(){return this.cell.recurrentConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasConstraint",{get:function(){return this.cell.biasConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropout",{get:function(){return this.cell.dropout},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentDropout",{get:function(){return this.cell.recurrentDropout},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"implementation",{get:function(){return this.cell.implementation},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GRU"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(y);n.GRU=E,g.ClassNameMap.register("GRU",E);var _=function(e){function t(t){var n=e.call(this,t)||this;return n.DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,n.activation=o.getActivation(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=o.getActivation(void 0===t.activation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=h.getInitializer(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=h.getInitializer(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=h.getInitializer(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.unitForgetBias=t.unitForgetBias,n.kernelRegularizer=d.getRegularizer(t.kernelRegularizer),n.recurrentRegularizer=d.getRegularizer(t.recurrentRegularizer),n.biasRegularizer=d.getRegularizer(t.biasRegularizer),n.kernelConstraint=u.getConstraint(t.kernelConstraint),n.recurrentConstraint=u.getConstraint(t.recurrentConstraint),n.biasConstraint=u.getConstraint(t.biasConstraint),n.dropout=m.min([1,m.max([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=m.min([1,m.max([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.implementation=t.implementation,n.stateSize=[n.units,n.units],n}return r(t,e),t.prototype.build=function(e){var t=(e=g.getExactlyOneShape(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);var n;if(this.useBias){if(this.unitForgetBias){var i=this.biasInitializer,a=this.units;n=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.apply=function(e,t){var n=i.apply([a]),r=(new h.Ones).apply([a]),o=i.apply([2*a]);return s.concatAlongFirstAxis(s.concatAlongFirstAxis(n,r),o)},t.prototype.getClassName=function(){return"CustomInit"},t}(h.Initializer))}else n=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,n,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0},t.prototype.call=function(e,t){if(0!==this.dropout||0!==this.recurrentDropout)throw new p.NotImplementedError("Dropout is not implemented for LSTMCell yet");if(3!==(e=e).length)throw new p.ValueError("LSTMCell expects 3 input Tensors (inputs, h, c), got "+e.length+".");var n=e[1],r=e[2];e=e[0];var i,a,o,u;if(1===this.implementation){var l=s.sliceAlongLastAxis(this.kernel.read(),0,this.units),c=s.sliceAlongLastAxis(this.kernel.read(),this.units,this.units),h=s.sliceAlongLastAxis(this.kernel.read(),2*this.units,this.units),d=s.sliceAlongLastAxis(this.kernel.read(),3*this.units,this.units),f=s.sliceAlongLastAxis(this.recurrentKernel.read(),0,this.units),g=s.sliceAlongLastAxis(this.recurrentKernel.read(),this.units,this.units),m=s.sliceAlongLastAxis(this.recurrentKernel.read(),2*this.units,this.units),v=s.sliceAlongLastAxis(this.recurrentKernel.read(),3*this.units,this.units),y=e,b=e,w=e,x=e,A=s.dot(y,l),E=s.dot(b,c),_=s.dot(w,h),T=s.dot(x,d);if(this.useBias){var S=s.sliceAlongFirstAxis(this.bias.read(),0,this.units),C=s.sliceAlongFirstAxis(this.bias.read(),this.units,this.units),O=s.sliceAlongFirstAxis(this.bias.read(),2*this.units,this.units),k=s.sliceAlongFirstAxis(this.bias.read(),3*this.units,this.units);A=s.biasAdd(A,S),E=s.biasAdd(E,C),_=s.biasAdd(_,O),T=s.biasAdd(T,k)}var R=n,N=n,I=n,z=n;i=this.recurrentActivation(s.add(A,s.dot(R,f))),a=this.recurrentActivation(s.add(E,s.dot(N,g))),o=s.add(s.multiply(a,r),s.multiply(i,this.activation(s.add(_,s.dot(I,m))))),u=this.recurrentActivation(s.add(T,s.dot(z,v)))}else{var M=s.dot(e,this.kernel.read());M=s.add(M,s.dot(n,this.recurrentKernel.read())),this.useBias&&(M=s.biasAdd(M,this.bias.read()));var D=s.sliceAlongLastAxis(M,0,this.units),P=s.sliceAlongLastAxis(M,this.units,this.units),L=s.sliceAlongLastAxis(M,2*this.units,this.units),F=s.sliceAlongLastAxis(M,3*this.units,this.units);i=this.recurrentActivation(D),a=this.recurrentActivation(P),o=s.add(s.multiply(a,r),s.multiply(i,this.activation(L))),u=this.recurrentActivation(F)}var V=s.multiply(u,this.activation(o));return[V,V,o]},t.prototype.getClassName=function(){return"LSTMCell"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(b);n.LSTMCell=_,g.ClassNameMap.register("LSTMCell",_);var T=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new _(t),e.call(this,t)||this}return r(t,e),t.prototype.call=function(t,n){var r=null==n?null:n.mask,i=null==n?null:n.training,a=null==n?null:n.initialState;return e.prototype.call.call(this,t,{mask:r,training:i,initialState:a})},Object.defineProperty(t.prototype,"units",{get:function(){return this.cell.units},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"activation",{get:function(){return this.cell.activation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBias",{get:function(){return this.cell.useBias},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelInitializer",{get:function(){return this.cell.kernelInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentInitializer",{get:function(){return this.cell.recurrentInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasInitializer",{get:function(){return this.cell.biasInitializer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"unitForgetBias",{get:function(){return this.cell.unitForgetBias},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelRegularizer",{get:function(){return this.cell.kernelRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentRegularizer",{get:function(){return this.cell.recurrentRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasRegularizer",{get:function(){return this.cell.biasRegularizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernelConstraint",{get:function(){return this.cell.kernelConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentConstraint",{get:function(){return this.cell.recurrentConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"biasConstraint",{get:function(){return this.cell.biasConstraint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropout",{get:function(){return this.cell.dropout},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"recurrentDropout",{get:function(){return this.cell.recurrentDropout},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"implementation",{get:function(){return this.cell.implementation},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"LSTM"},t.prototype.getConfig=function(){var t={units:this.units,activation:o.serializeActivation(this.activation),useBias:this.useBias,kernelInitializer:h.serializeInitializer(this.kernelInitializer),recurrentInitializer:h.serializeInitializer(this.recurrentInitializer),biasInitializer:h.serializeInitializer(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:d.serializeRegularizer(this.kernelRegularizer),recurrentRegularizer:d.serializeRegularizer(this.recurrentRegularizer),biasRegularizer:d.serializeRegularizer(this.biasRegularizer),activityRegularizer:d.serializeRegularizer(this.activityRegularizer),kernelConstraint:u.serializeConstraint(this.kernelConstraint),recurrentConstraint:u.serializeConstraint(this.recurrentConstraint),biasConstraint:u.serializeConstraint(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(y);n.LSTM=T,g.ClassNameMap.register("LSTM",T);var S=function(e){function t(t){var n=e.call(this,t)||this;return n.cells=t.cells,n}return r(t,e),Object.defineProperty(t.prototype,"stateSize",{get:function(){for(var e=[],t=0,n=this.cells.slice().reverse();t= 3D, but received input shape "+JSON.stringify(t));this.inputSpec=[{shape:t}];var n=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),e.prototype.build.call(this,t)},t.prototype.computeOutputShape=function(e){var t=[(e=s.getExactlyOneShape(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))},t.prototype.call=function(e,t){var n=this;e=s.getExactlyOneTensor(e);return i.rnn(function(e,r){return[n.layer.call(e,t),[]]},e,[],!1,null,null,!1,e.shape[1])[1]},t.prototype.getClassName=function(){return"TimeDistributed"},t}(l);n.TimeDistributed=c,s.ClassNameMap.register("TimeDistributed",c);var p;!function(e){e[e.SUM=0]="SUM",e[e.MUL=1]="MUL",e[e.CONCAT=2]="CONCAT",e[e.AVE=3]="AVE"}(p=n.BidirectionalMergeMode||(n.BidirectionalMergeMode={})),s.SerializableEnumRegistry.register("merge_mode",{sum:p.SUM,mul:p.MUL,concat:p.CONCAT,ave:p.AVE});var h=function(e){function t(t){var n=e.call(this,t)||this;n.forwardLayer=t.layer;var r=t.layer.getConfig();if(r.goBackwards=!0!==r.goBackwards,n.backwardLayer=u.deserialize({className:t.layer.getClassName(),config:r}),n.forwardLayer.name="forward_"+n.forwardLayer.name,n.backwardLayer.name="backward_"+n.backwardLayer.name,n.mergeMode=t.mergeMode,t.weights)throw new o.NotImplementedError("weights support is not implemented for Bidirectional layer yet.");return n._stateful=t.layer.stateful,n.returnSequences=t.layer.returnSequences,n.returnState=t.layer.returnState,n.supportsMasking=!0,n._trainable=!0,n.inputSpec=t.layer.inputSpec,n}return r(t,e),Object.defineProperty(t.prototype,"trainable",{get:function(){return this._trainable},set:function(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)},enumerable:!0,configurable:!0}),t.prototype.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},t.prototype.setWeights=function(e){var t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))},t.prototype.computeOutputShape=function(e){var t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;var n,r,i;return this.returnState?(i=t.slice(1),n=t[0]):n=t[0],n=n,this.mergeMode===p.CONCAT?(n[n.length-1]*=2,r=[n]):r=null==this.mergeMode?[n,n.slice()]:[n],this.returnState?null==this.mergeMode?r.concat(i).concat(i.slice()):[n].concat(i).concat(i.slice()):s.singletonOrArray(r)},t.prototype.apply=function(t,n){var r=null;if(null!=n&&(r=n.initialState),Array.isArray(t)&&(r=t.slice(1),t=t[0]),null==r||0===r.length)return e.prototype.apply.call(this,t,n);throw new o.NotImplementedError("The support for initial states is not implemented for Bidirectional layers yet.")},t.prototype.call=function(e,t){if(null!=t.mask)throw new o.NotImplementedError("The support for masking is not implemented for Bidirectional layers yet.");if(null!=t.initialState)throw new o.NotImplementedError("The support for initial states is not implemented for Bidirectional layers yet.");var n,r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);this.returnState&&(Array.isArray(r)&&(n=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=i.reverse(a,1));var s;return this.mergeMode===p.CONCAT?s=i.concatenate([r,a]):this.mergeMode===p.SUM?s=i.add(r,a):this.mergeMode===p.AVE?s=i.scalarTimesArray(i.getScalar(.5),i.add(r,a)):this.mergeMode===p.MUL?s=i.multiply(r,a):null==this.mergeMode&&(s=[r,a]),this.returnState?null==this.mergeMode?s.concat(n):[s].concat(n):s},t.prototype.resetStates=function(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()},t.prototype.build=function(e){var t=this;i.nameScope(this.forwardLayer.name,function(){t.forwardLayer.build(e)}),i.nameScope(this.backwardLayer.name,function(){t.backwardLayer.build(e)}),this.built=!0},Object.defineProperty(t.prototype,"trainableWeights",{get:function(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nonTrainableWeights",{get:function(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Bidirectional"},t}(l);n.Bidirectional=h,s.ClassNameMap.register("Bidirectional",h)},{"../backend/tfjs_backend":100,"../engine/topology":105,"../errors":107,"../utils/generic_utils":130,"./serialization":121}],123:[function(e,t,n){"use strict";function r(e,t){return v.mean(v.square(v.subtract(t,e)),-1)}function i(e,t){return v.mean(v.abs(v.subtract(t,e)),-1)}function a(e,t){var n=v.subtract(e,t),r=v.clip(v.abs(e),v.epsilon(),Number.MAX_VALUE),i=v.abs(v.divide(n,r));return v.scalarTimesArray(v.getScalar(100),v.mean(i,-1))}function o(e,t){var n=v.getScalar(1),r=v.clip(t,v.epsilon(),Number.MAX_VALUE),i=v.log(v.scalarPlusArray(n,r)),a=v.clip(e,v.epsilon(),Number.MAX_VALUE),o=v.log(v.scalarPlusArray(n,a));return v.mean(v.square(v.subtract(i,o)),-1)}function s(e,t){var n=v.getScalar(0),r=v.getScalar(1),i=v.maximum(n,v.subtract(r,v.multiply(e,t)));return v.mean(v.square(i),-1)}function u(e,t){var n=v.getScalar(0),r=v.getScalar(1),i=v.maximum(n,v.subtract(r,v.multiply(e,t)));return v.mean(i,-1)}function l(e,t){var n=v.getScalar(0),r=v.getScalar(1),i=v.sum(v.multiply(e,t),-1),a=v.max(v.multiply(v.subtract(r,e),t),-1);return v.maximum(n,v.scalarPlusArray(r,v.subtract(a,i)))}function c(e,t){var n=v.getScalar(Math.log(2)),r=v.subtract(t,e),i=v.subtract(v.add(r,v.softplus(v.scalarTimesArray(v.getScalar(-2),r))),n);return v.mean(i,-1)}function p(e,t){return v.categoricalCrossentropy(e,t)}function h(e,t){return v.sparseCategoricalCrossentropy(e,t)}function d(e,t){return v.mean(v.binaryCrossentropy(e,t),-1)}function f(e,t){var n=v.clip(e,v.epsilon(),1),r=v.clip(t,v.epsilon(),1);return v.sum(v.multiply(e,v.log(v.divide(n,r))),-1)}function g(e,t){var n=v.log(v.scalarPlusArray(v.getScalar(v.epsilon()),t));return v.mean(v.subtract(t,v.multiply(e,n)),-1)}function m(e,t){var n=v.l2Normalize(e,-1),r=v.l2Normalize(t,-1),i=v.multiply(n,r);return v.neg(v.sum(i,-1))}Object.defineProperty(n,"__esModule",{value:!0});var v=e("./backend/tfjs_backend"),y=e("./errors");n.meanSquaredError=r,n.meanAbsoluteError=i,n.meanAbsolutePercentageError=a,n.meanSquaredLogarithmicError=o,n.squaredHinge=s,n.hinge=u,n.categoricalHinge=l,n.logcosh=c,n.categoricalCrossentropy=p,n.sparseCategoricalCrossentropy=h,n.binaryCrossentropy=d,n.kullbackLeiblerDivergence=f,n.poisson=g,n.cosineProximity=m,n.mse=r,n.MSE=r,n.mae=i,n.MAE=i,n.mape=a,n.MAPE=a,n.msle=o,n.MSLE=o,n.kld=f,n.KLD=f,n.cosine=m,n.get=function(e){var t={meanSquaredError:r,meanAbsoluteError:i,meanAbsolutePercentageError:a,meanSquaredLogarithmicError:o,squaredHinge:s,hinge:u,categoricalHinge:l,logcosh:c,categoricalCrossentropy:p,sparseCategoricalCrossentropy:h,binaryCrossentropy:d,kullbackLeiblerDivergence:f,poisson:g,cosineProximity:m};if("string"==typeof e){if(e in t)return t[e];throw new y.ValueError("Unknown loss "+e)}return e}},{"./backend/tfjs_backend":100,"./errors":107}],124:[function(e,t,n){"use strict";function r(e,t){var n=o.scalarTimesArray(o.getScalar(.5),a.onesLike(t)),r=o.cast(o.greater(t,n),e.dtype);return o.mean(o.equal(e,r),-1)}function i(e,t){return o.cast(o.equal(o.argmax(e,-1),o.argmax(t,-1)),"float32")}Object.defineProperty(n,"__esModule",{value:!0});var a=e("@tensorflow/tfjs-core"),o=e("./backend/tfjs_backend"),s=e("./errors"),u=e("./losses");n.binaryAccuracy=r,n.categoricalAccuracy=i,n.binaryCrossentropy=function(e,t){return o.mean(o.binaryCrossentropy(e,t),-1)},n.sparseCategoricalAccuracy=function(e,t){throw new s.NotImplementedError},n.topKCategoricalAccuracy=function(e,t){throw new s.NotImplementedError},n.sparseTopKCategoricalAccuracy=function(e,t){throw new s.NotImplementedError},n.mse=u.meanSquaredError,n.MSE=u.meanSquaredError,n.mae=u.meanAbsoluteError,n.MAE=u.meanAbsoluteError,n.mape=u.meanAbsolutePercentageError,n.MAPE=u.meanAbsolutePercentageError,n.categoricalCrossentropy=u.categoricalCrossentropy,n.cosine=u.cosineProximity,n.sparseCategoricalCrossentropy=u.sparseCategoricalCrossentropy,n.get=function(e){var t={binaryAccuracy:r,categoricalAccuracy:i,categoricalCrossentropy:n.categoricalCrossentropy,sparseCategoricalCrossentropy:n.sparseCategoricalCrossentropy,mse:n.mse,MSE:n.MSE,mae:n.mae,MAE:n.MAE,mape:n.mape,MAPE:n.MAPE,cosine:n.cosine};if("string"==typeof e&&e in t)return t[e];if("string"!=typeof e&&null!=e)return e;throw new s.ValueError("Unknown metric "+e)}},{"./backend/tfjs_backend":100,"./errors":107,"./losses":123,"@tensorflow/tfjs-core":8}],125:[function(e,t,n){"use strict";function r(e,t){return o(this,void 0,void 0,function(){var n,r,i,a,o,l,c,p,h,f;return s(this,function(s){switch(s.label){case 0:return null!=(n=e.modelTopology).model_config&&(n=n.model_config),r=g.convertPythonicToTs(n),i=d.deserialize(r,t),null==e.weightsManifest?[3,2]:[4,u.loadWeights(e.weightsManifest,e.pathPrefix,i.weights.map(function(e){return e.originalName}))];case 1:for(a=s.sent(),o={},l=0,c=i.weights;l=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,a){function o(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(o=a[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(a,n[1])).done)return o;switch(a=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(o=u.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var o=e("@tensorflow/tfjs-core"),s=e("./backend/tfjs_backend"),u=e("./types"),l=e("./utils/generic_utils"),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(u.Serializable);n.Regularizer=c;var p=function(e){function t(t){var n=e.call(this)||this,r=null==t||null==t.l1?.01:t.l1,i=null==t||null==t.l2?.01:t.l2;return n.hasL1=0!==r,n.hasL2=0!==i,n.l1=s.getScalar(r),n.l2=s.getScalar(i),n}return i(t,e),n=t,t.prototype.apply=function(e){var t=o.zeros([1]);return this.hasL1&&(t=s.add(t,s.sum(s.scalarTimesArray(this.l1,s.abs(e))))),this.hasL2&&(t=s.add(t,s.sum(s.scalarTimesArray(this.l2,s.square(e))))),t.asScalar()},t.prototype.getClassName=function(){return"L1L2"},t.prototype.getConfig=function(){return{l1:this.l1.dataSync()[0],l2:this.l2.dataSync()[0]}},t.fromConfig=function(e,t){return new n({l1:t.l1,l2:t.l2})},t=n=a([o.doc({heading:"Regularizers",namespace:"regularizers"})],t);var n}(c);n.L1L2=p,l.ClassNameMap.register("L1L2",p),n.l1=function(e){return new p({l1:null!=e?e.l1:null,l2:0})},n.l2=function(e){return new p({l2:null!=e?e.l2:null,l1:0})},n.REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP={l1l2:"L1L2"},n.serializeRegularizer=function(e){return l.serializeKerasObject(e)},n.deserializeRegularizer=r,n.getRegularizer=function(e){return null==e?null:"string"==typeof e?r({className:e in n.REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP?n.REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP[e]:e,config:{}}):e instanceof c?e:r(e)}},{"./backend/tfjs_backend":100,"./types":128,"./utils/generic_utils":130,"@tensorflow/tfjs-core":8}],128:[function(e,t,n){"use strict";function r(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}function i(e){return e instanceof p?e.value():e}var a=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o};Object.defineProperty(n,"__esModule",{value:!0});var o,s=e("@tensorflow/tfjs-core"),u=e("./common");!function(e){e.float32="float32",e.int32="int32",e.bool="bool"}(o=n.DType||(n.DType={}));var l=0,c=function(){function e(e,t,n,r,i,a,o){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=i,this.outputTensorIndex=o,this.id=l++,null!=a&&(this.originalName=u.getScopedTensorName(a),this.name=u.getUniqueTensorName(this.originalName))}return e=a([s.doc({heading:"Models",subheading:"Classes"})],e)}();n.SymbolicTensor=c;var p=function(){function e(e,t){this.dtype=o.float32,this.shape=e.shape,this.val=e,this.id=l++,null!=t&&(this.originalName=u.getScopedTensorName(t),this.name=u.getUniqueTensorName(this.originalName))}return e.prototype.value=function(){return this.val},e}();n.ConcreteTensor=p;var h="Variable",d=function(){function e(e,t,n,r,a){void 0===t&&(t=o.float32),void 0===n&&(n=h),void 0===r&&(r=!0),void 0===a&&(a=null),this.dtype=null==t?o.float32:t,this.shape=e.shape,this.id=l++,n=null==n?h:n,this.originalName=u.getScopedTensorName(n),this.name=u.getUniqueTensorName(this.originalName),this.trainable=r,this.constraint=a,this.val=s.variable(i(e),this.trainable,this.name,this.dtype)}return e.prototype.read=function(){return this.val},e.prototype.write=function(e){return r(this.val,e),this.val.assign(i(e)),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val)),this},e}();n.LayerVariable=d;var f=function(){return function(){}}();n.Serializable=f},{"./common":102,"@tensorflow/tfjs-core":8}],129:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("../errors"),i=e("./generic_utils"),a=e("./math_utils");n.normalizeArray=function(e,t,n){if("number"==typeof e)return i.pyListRepeat(e,t);if(e.length!==t)throw new r.ValueError("The "+n+" argument must be a tuple of "+t+" integers. Received: "+e.length+" elements.");for(var o=0;ot?1:0}var a=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length)throw new o.IndexError(n);return t},n.assert=function(e,t){if(!e)throw new o.AssertionError(t)},n.count=function(e,t){for(var n=0,r=0,i=e;r>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)}}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.alea=a}(0,"object"==typeof t&&t,!1)},{}],137:[function(e,t,n){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.tychei=a}(0,"object"==typeof t&&t,!1)},{}],138:[function(e,t,n){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor128=a}(0,"object"==typeof t&&t,!1)},{}],139:[function(e,t,n){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,i=t.X,a=t.i;return t.w=r=r+1640531527|0,n=i[a+34&127],e=i[a=a+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=i[a]=n^e,t.i=a,n+(r^r>>>16)|0},function(e,t){var n,r,i,a,o,s=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,r^=r<<4,r^=r>>>13,a>=0&&(o=o+1640531527|0,i=0==(n=s[127&a]^=r+o)?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;e.w=o,e.X=s,e.i=i}(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&(a.X&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor4096=a}(0,"object"==typeof t&&t,!1)},{}],140:[function(e,t,n){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,i=t.i;return e=r[i],e^=e>>>7,n=e^e<<24,e=r[i+1&7],n^=e^e>>>10,e=r[i+3&7],n^=e^e>>>3,e=r[i+4&7],n^=e^e<<7,e=r[i+7&7],e^=e<<13,n^=e^e<<9,r[i]=n,t.i=i+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&(a.x&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorshift7=a}(0,"object"==typeof t&&t,!1)},{}],141:[function(e,t,n){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorwow=a}(0,"object"==typeof t&&t,!1)},{}],142:[function(e,t,n){!function(n,r){function i(e,t,i){var p=[],h=u(s((t=1==t?{entropy:!0}:t||{}).entropy?[e,c(n)]:null==e?l():e,3),p),b=new a(p),w=function(){for(var e=b.g(f),t=m,n=0;e=y;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|b.g(4)},w.quick=function(){return b.g(4)/4294967296},w.double=w,u(c(b.S),n),(t.pass||i||function(e,t,n,i){return i&&(i.S&&o(i,b),e.state=function(){return o(b,{})}),n?(r[g]=e,t):e})(w,h,"global"in t?t.global:this==r,t.state)}function a(e){var t,n=e.length,r=this,i=0,a=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);i