UNPKG

3.08 kBSource Map (JSON)View Raw
1{"version":3,"file":"clip_by_value.js","sourceRoot":"","sources":["../../src/ops/clip_by_value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,WAAW,EAAsC,MAAM,iBAAiB,CAAC;AAIjF,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AACH,SAAS,YAAY,CACjB,CAAe,EAAE,YAAoB,EAAE,YAAoB;IAC7D,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,CACP,CAAC,YAAY,IAAI,YAAY,CAAC,EAC9B,GAAG,EAAE,CAAC,uBAAuB,YAAY,YAAY;QACjD,8BAA8B,YAAY,IAAI,CAAC,CAAC;IAExD,MAAM,MAAM,GAAsB,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC;IAC1C,MAAM,KAAK,GAAqB,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC;IAE7D,OAAO,MAAM,CAAC,SAAS,CACnB,WAAW,EAAE,MAA8B,EAAE,KAA2B,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC,EAAC,YAAY,EAAC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * =============================================================================\n */\nimport {ENGINE} from '../engine';\nimport {ClipByValue, ClipByValueAttrs, ClipByValueInputs} from '../kernel_names';\nimport {NamedAttrMap} from '../kernel_registry';\nimport {Tensor} from '../tensor';\nimport {NamedTensorMap} from '../tensor_types';\nimport {convertToTensor} from '../tensor_util_env';\nimport {TensorLike} from '../types';\nimport * as util from '../util';\n\nimport {op} from './operation';\n\n/**\n * Clips values element-wise. `max(min(x, clipValueMax), clipValueMin)`\n *\n * ```js\n * const x = tf.tensor1d([-1, 2, -3, 4]);\n *\n * x.clipByValue(-2, 3).print(); // or tf.clipByValue(x, -2, 3)\n * ```\n * @param x The input tensor.\n * @param clipValueMin Lower-bound of range to be clipped to.\n * @param clipValueMax Upper-bound of range to be clipped to.\n *\n * @doc {heading: 'Operations', subheading: 'Basic math'}\n */\nfunction clipByValue_<T extends Tensor>(\n x: T|TensorLike, clipValueMin: number, clipValueMax: number): T {\n const $x = convertToTensor(x, 'x', 'clipByValue');\n util.assert(\n (clipValueMin <= clipValueMax),\n () => `Error in clip: min (${clipValueMin}) must be ` +\n `less than or equal to max (${clipValueMax}).`);\n\n const inputs: ClipByValueInputs = {x: $x};\n const attrs: ClipByValueAttrs = {clipValueMin, clipValueMax};\n\n return ENGINE.runKernel(\n ClipByValue, inputs as {} as NamedTensorMap, attrs as {} as NamedAttrMap);\n}\n\nexport const clipByValue = op({clipByValue_});\n"]}
\No newline at end of file