@tensorflow/tfjs-converter
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -38,5 +38,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tfc = require("@tensorflow/tfjs-core"); | ||
var fs = require("fs"); | ||
var node_fetch_1 = require("node-fetch"); | ||
var arithmetic = require("../src/operations/op_list/arithmetic"); | ||
@@ -57,46 +55,43 @@ var basicMath = require("../src/operations/op_list/basic_math"); | ||
var transformation = require("../src/operations/op_list/transformation"); | ||
var DOC_DIR = './docs/'; | ||
var opMappers = arithmetic.json.concat(basicMath.json, control.json, convolution.json, creation.json, dynamic.json, evaluation.json, logical.json, image.json, graph.json, matrices.json, normalization.json, reduction.json, sliceJoin.json, transformation.json); | ||
var GITHUB_URL_PREFIX = 'https://raw.githubusercontent.com/tensorflow/tfjs-website'; | ||
var CORE_API_PREFIX = "/master/source/_data/api/" + tfc.version_core + "/tfjs-core.json"; | ||
var JSON_DIR = './tfjs-core.json'; | ||
var DOC_DIR = './'; | ||
var ops = [ | ||
arithmetic, basicMath, control, convolution, creation, dynamic, evaluation, | ||
logical, image, graph, matrices, normalization, reduction, sliceJoin, | ||
transformation | ||
]; | ||
function genDoc() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, json, coreApis, output; | ||
var json, coreApis, output; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, node_fetch_1.default(GITHUB_URL_PREFIX + CORE_API_PREFIX)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [4, response.json()]; | ||
case 2: | ||
json = _a.sent(); | ||
coreApis = json.docs.headings.reduce(function (list, h) { | ||
return h.subheadings ? list.concat(h.subheadings.reduce(function (sublist, sub) { | ||
return sublist.concat(sub.symbols); | ||
}, [])) : | ||
list; | ||
}, []); | ||
output = []; | ||
output.push('# Supported Tensorflow Ops\n\n'); | ||
generateTable('Operations', 'Arithmetic', arithmetic.json, output, coreApis); | ||
generateTable('Operations', 'Basic math', basicMath.json, output, coreApis); | ||
generateTable('Operations', 'Control Flow', control.json, output, coreApis); | ||
generateTable('Operations', 'Convolution', convolution.json, output, coreApis); | ||
generateTable('Tensors', 'Creation', creation.json, output, coreApis); | ||
generateTable('Operations', 'Dynamic', dynamic.json, output, coreApis); | ||
generateTable('Operations', 'Evaluation', evaluation.json, output, coreApis); | ||
generateTable('Tensorflow', 'Graph', graph.json, output, coreApis); | ||
generateTable('Operations', 'Logical', logical.json, output, coreApis); | ||
generateTable('Operations', 'Matrices', matrices.json, output, coreApis); | ||
generateTable('Operations', 'Normalization', normalization.json, output, coreApis); | ||
generateTable('Operations', 'Images', image.json, output, coreApis); | ||
generateTable('Operations', 'Reduction', reduction.json, output, coreApis); | ||
generateTable('Tensors', 'Slicing and Joining', sliceJoin.json, output, coreApis); | ||
generateTable('Tensors', 'Transformations', transformation.json, output, coreApis); | ||
console.log(process.cwd()); | ||
fs.writeFileSync(DOC_DIR + 'supported_ops.md', output.join('')); | ||
console.log("Supported Ops written to " + (DOC_DIR + 'supported_ops.md') + "\n" + | ||
("Found " + opMappers.length + " ops\n")); | ||
return [2]; | ||
} | ||
json = JSON.parse(fs.readFileSync(JSON_DIR, 'utf8')); | ||
coreApis = json.docs.headings.reduce(function (list, h) { | ||
return h.subheadings ? list.concat(h.subheadings.reduce(function (sublist, sub) { | ||
return sublist.concat(sub.symbols); | ||
}, [])) : | ||
list; | ||
}, []); | ||
output = []; | ||
output.push('# Supported Tensorflow Ops\n\n'); | ||
generateTable('Operations', 'Arithmetic', arithmetic.json, output, coreApis); | ||
generateTable('Operations', 'Basic math', basicMath.json, output, coreApis); | ||
generateTable('Operations', 'Control Flow', control.json, output, coreApis); | ||
generateTable('Operations', 'Convolution', convolution.json, output, coreApis); | ||
generateTable('Tensors', 'Creation', creation.json, output, coreApis); | ||
generateTable('Operations', 'Dynamic', dynamic.json, output, coreApis); | ||
generateTable('Operations', 'Evaluation', evaluation.json, output, coreApis); | ||
generateTable('Tensorflow', 'Graph', graph.json, output, coreApis); | ||
generateTable('Operations', 'Logical', logical.json, output, coreApis); | ||
generateTable('Operations', 'Matrices', matrices.json, output, coreApis); | ||
generateTable('Operations', 'Normalization', normalization.json, output, coreApis); | ||
generateTable('Operations', 'Images', image.json, output, coreApis); | ||
generateTable('Operations', 'Reduction', reduction.json, output, coreApis); | ||
generateTable('Tensors', 'Slicing and Joining', sliceJoin.json, output, coreApis); | ||
generateTable('Operations', 'Spectral', [], output, coreApis); | ||
generateTable('Tensors', 'Transformations', transformation.json, output, coreApis); | ||
console.log(process.cwd()); | ||
fs.writeFileSync(DOC_DIR + 'supported_ops.md', output.join('')); | ||
console.log("Supported Ops written to " + (DOC_DIR + 'supported_ops.md') + "\n" + | ||
("Found " + ops.reduce(function (sum, cat) { return sum += cat.json.length; }, 0) + " ops\n")); | ||
return [2]; | ||
}); | ||
@@ -124,5 +119,5 @@ }); | ||
}); | ||
output.push('\n\n'); | ||
output.push('\n'); | ||
} | ||
genDoc(); | ||
//# sourceMappingURL=gen_doc.js.map |
@@ -190,6 +190,6 @@ "use strict"; | ||
GraphExecutor.prototype.getFrozenTensorIds = function (tensorMap) { | ||
var ids = Object.keys(tensorMap) | ||
var ids = [].concat.apply([], Object.keys(tensorMap) | ||
.map(function (key) { return tensorMap[key]; }) | ||
.map(function (tensors) { return tensors.map(function (tensor) { return tensor.id; }); }); | ||
return new (Set.bind.apply(Set, [void 0].concat(ids)))(); | ||
.map(function (tensors) { return tensors.map(function (tensor) { return tensor.id; }); })); | ||
return new Set(ids); | ||
}; | ||
@@ -196,0 +196,0 @@ GraphExecutor.prototype.checkTensorForDisposal = function (nodeName, node, tensorMap, context, tensorsToKeep, intermediateTensorConsumerCount) { |
@@ -19,2 +19,4 @@ "use strict"; | ||
return [tfc.atan(utils_1.getParamValue('x', node, tensorMap, context))]; | ||
case 'atan2': | ||
return [tfc.atan2(utils_1.getParamValue('x', node, tensorMap, context), utils_1.getParamValue('y', node, tensorMap, context))]; | ||
case 'atanh': | ||
@@ -86,2 +88,4 @@ return [tfc.atanh(utils_1.getParamValue('x', node, tensorMap, context))]; | ||
return [tfc.prod(utils_1.getParamValue('x', node, tensorMap, context), utils_1.getParamValue('axes', node, tensorMap, context))]; | ||
case 'leakyRelu': | ||
return [tfc.leakyRelu(utils_1.getParamValue('x', node, tensorMap, context), utils_1.getParamValue('alpha', node, tensorMap, context))]; | ||
default: | ||
@@ -88,0 +92,0 @@ throw TypeError("Node type " + node.op + " is not implemented"); |
@@ -50,4 +50,5 @@ "use strict"; | ||
case 'whereAsync': return [3, 3]; | ||
case 'setdiff1dAsync': return [3, 5]; | ||
} | ||
return [3, 5]; | ||
return [3, 7]; | ||
case 1: | ||
@@ -63,3 +64,5 @@ boxes = utils_1.getParamValue('boxes', node, tensorMap, context); | ||
case 4: return [2, [_b.sent()]]; | ||
case 5: throw TypeError("Node type " + node.op + " is not implemented"); | ||
case 5: return [4, tfc.setdiff1dAsync(utils_1.getParamValue('x', node, tensorMap, context), utils_1.getParamValue('y', node, tensorMap, context))]; | ||
case 6: return [2, _b.sent()]; | ||
case 7: throw TypeError("Node type " + node.op + " is not implemented"); | ||
} | ||
@@ -66,0 +69,0 @@ }); |
@@ -16,2 +16,8 @@ "use strict"; | ||
} | ||
case 'logSoftmax': { | ||
return [tfc.logSoftmax(utils_1.getParamValue('x', node, tensorMap, context))]; | ||
} | ||
case 'sparseToDense': { | ||
return [tfc.sparseToDense(utils_1.getParamValue('sparseIndices', node, tensorMap, context), utils_1.getParamValue('outputShape', node, tensorMap, context), utils_1.getParamValue('sparseValues', node, tensorMap, context), utils_1.getParamValue('defaultValue', node, tensorMap, context))]; | ||
} | ||
default: | ||
@@ -18,0 +24,0 @@ throw TypeError("Node type " + node.op + " is not implemented"); |
@@ -34,2 +34,7 @@ "use strict"; | ||
} | ||
case 'depthToSpace': { | ||
var blockSize = utils_1.getParamValue('blockSize', node, tensorMap, context); | ||
var dataFormat = utils_1.getParamValue('dataFormat', node, tensorMap, context); | ||
return [tfc.depthToSpace(utils_1.getParamValue('x', node, tensorMap, context), blockSize, dataFormat)]; | ||
} | ||
default: | ||
@@ -36,0 +41,0 @@ throw TypeError("Node type " + node.op + " is not implemented"); |
@@ -42,2 +42,28 @@ export declare const json: ({ | ||
})[]; | ||
} | { | ||
'tfOpName': string; | ||
'dlOpName': string; | ||
'category': string; | ||
'params': ({ | ||
'tfInputIndex': number; | ||
'dlParamName': string; | ||
'type': string; | ||
tfParamName?: undefined; | ||
defaultValue?: undefined; | ||
notSupported?: undefined; | ||
} | { | ||
'tfParamName': string; | ||
'dlParamName': string; | ||
'type': string; | ||
'defaultValue': number; | ||
tfInputIndex?: undefined; | ||
notSupported?: undefined; | ||
} | { | ||
'tfParamName': string; | ||
'dlParamName': string; | ||
'type': string; | ||
'notSupported': boolean; | ||
tfInputIndex?: undefined; | ||
defaultValue?: undefined; | ||
})[]; | ||
})[]; |
@@ -44,3 +44,3 @@ "use strict"; | ||
{ | ||
'tfOpName': 'atan', | ||
'tfOpName': 'Atan', | ||
'dlOpName': 'atan', | ||
@@ -58,2 +58,16 @@ 'category': 'basic_math', | ||
{ | ||
'tfOpName': 'Atan2', | ||
'dlOpName': 'atan2', | ||
'category': 'basic_math', | ||
'params': [ | ||
{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }, | ||
{ 'tfInputIndex': 1, 'dlParamName': 'y', 'type': 'tensor' }, { | ||
'tfParamName': 'T', | ||
'dlParamName': 'dtype', | ||
'type': 'dtype', | ||
'notSupported': true | ||
} | ||
] | ||
}, | ||
{ | ||
'tfOpName': 'Ceil', | ||
@@ -486,4 +500,23 @@ 'dlOpName': 'ceil', | ||
] | ||
}, | ||
{ | ||
'tfOpName': 'LeakyRelu', | ||
'dlOpName': 'leakyRelu', | ||
'category': 'basic_math', | ||
'params': [ | ||
{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }, { | ||
'tfParamName': 'alpha', | ||
'dlParamName': 'alpha', | ||
'type': 'number', | ||
'defaultValue': 0.2 | ||
}, | ||
{ | ||
'tfParamName': 'T', | ||
'dlParamName': 'dtype', | ||
'type': 'dtype', | ||
'notSupported': true | ||
} | ||
] | ||
} | ||
]; | ||
//# sourceMappingURL=basic_math.js.map |
@@ -39,4 +39,18 @@ "use strict"; | ||
] | ||
}, | ||
{ | ||
'tfOpName': 'ListDiff', | ||
'dlOpName': 'setdiff1dAsync', | ||
'category': 'dynamic', | ||
'params': [ | ||
{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }, | ||
{ 'tfInputIndex': 1, 'dlParamName': 'y', 'type': 'tensor' }, { | ||
'tfParamName': 'T', | ||
'dlParamName': 'dtype', | ||
'type': 'dtype', | ||
'notSupported': true | ||
} | ||
] | ||
} | ||
]; | ||
//# sourceMappingURL=dynamic.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const json: { | ||
export declare const json: ({ | ||
'tfOpName': string; | ||
@@ -27,2 +27,21 @@ 'dlOpName': string; | ||
})[]; | ||
}[]; | ||
} | { | ||
'tfOpName': string; | ||
'dlOpName': string; | ||
'category': string; | ||
'params': ({ | ||
'tfInputIndex': number; | ||
'dlParamName': string; | ||
'type': string; | ||
tfParamName?: undefined; | ||
defaultValue?: undefined; | ||
notSupported?: undefined; | ||
} | { | ||
'tfParamName': string; | ||
'dlParamName': string; | ||
'type': string; | ||
'defaultValue': boolean; | ||
'notSupported': boolean; | ||
tfInputIndex?: undefined; | ||
})[]; | ||
})[]; |
@@ -86,4 +86,27 @@ "use strict"; | ||
'params': [{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }] | ||
}, | ||
{ | ||
'tfOpName': 'LogSoftmax', | ||
'dlOpName': 'logSoftmax', | ||
'category': 'normalization', | ||
'params': [{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }] | ||
}, | ||
{ | ||
'tfOpName': 'SparseToDense', | ||
'dlOpName': 'sparseToDense', | ||
'category': 'normalization', | ||
'params': [ | ||
{ 'tfInputIndex': 0, 'dlParamName': 'sparseIndices', 'type': 'tensor' }, | ||
{ 'tfInputIndex': 1, 'dlParamName': 'outputShape', 'type': 'number[]' }, | ||
{ 'tfInputIndex': 2, 'dlParamName': 'sparseValues', 'type': 'tensor' }, | ||
{ 'tfInputIndex': 3, 'dlParamName': 'defaultValue', 'type': 'tensor' }, { | ||
'tfParamName': 'validate_indices', | ||
'dlParamName': 'validateIndices', | ||
'type': 'bool', | ||
'defaultValue': true, | ||
'notSupported': true | ||
} | ||
] | ||
} | ||
]; | ||
//# sourceMappingURL=normalization.js.map |
@@ -100,4 +100,21 @@ "use strict"; | ||
] | ||
}, | ||
{ | ||
'tfOpName': 'DepthToSpace', | ||
'dlOpName': 'depthToSpace', | ||
'category': 'transformation', | ||
'params': [ | ||
{ 'tfInputIndex': 0, 'dlParamName': 'x', 'type': 'tensor' }, { | ||
'tfParamName': 'block_size', | ||
'dlParamName': 'blockSize', | ||
'type': 'number' | ||
}, | ||
{ | ||
'tfParamName': 'data_format', | ||
'dlParamName': 'dataFormat', | ||
'type': 'string' | ||
} | ||
] | ||
} | ||
]; | ||
//# sourceMappingURL=transformation.js.map |
import { Tensor } from '@tensorflow/tfjs-core'; | ||
export declare type ParamTypes = 'number' | 'string' | 'number[]' | 'bool' | 'shape' | 'tensor' | 'tensors' | 'dtype'; | ||
export declare type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'dynamic' | 'evaluation' | 'image' | 'creation' | 'graph' | 'logical' | 'matrices' | 'normalization' | 'reduction' | 'slice_join' | 'transformation'; | ||
export declare type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'dynamic' | 'evaluation' | 'image' | 'creation' | 'graph' | 'logical' | 'matrices' | 'normalization' | 'reduction' | 'slice_join' | 'spectral' | 'transformation'; | ||
export interface ParamMapper { | ||
@@ -5,0 +5,0 @@ tfParamName?: string; |
@@ -1,2 +0,2 @@ | ||
declare const version = "0.6.6"; | ||
declare const version = "0.6.7"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var version = '0.6.6'; | ||
var version = '0.6.7'; | ||
exports.version = version; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@tensorflow/tfjs-converter", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"description": "Tensorflow model converter for javascript", | ||
@@ -17,6 +17,6 @@ "main": "dist/src/index.js", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "0.13.10" | ||
"@tensorflow/tfjs-core": "0.13.11" | ||
}, | ||
"devDependencies": { | ||
"@tensorflow/tfjs-core": "0.13.10", | ||
"@tensorflow/tfjs-core": "0.13.11", | ||
"@types/jasmine": "~2.8.6", | ||
@@ -23,0 +23,0 @@ "@types/node-fetch": "1.6.9", |
@@ -16,3 +16,3 @@ [![Build Status](https://travis-ci.org/tensorflow/tfjs-converter.svg?branch=master)](https://travis-ci.org/tensorflow/tfjs-converter) | ||
## Step 1: Converting a [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [Keras h5](https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model), [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md), [Frozen Model](https://www.tensorflow.org/mobile/prepare_models#how_do_you_get_a_model_you_can_use_on_mobile) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) to a web-friendly format | ||
## Step 1: Converting a [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md), [Keras h5](https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model), [tf.keras SavedModel](https://www.tensorflow.org/api_docs/python/tf/contrib/saved_model/save_keras_model), [Session Bundle](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/session_bundle/README.md), [Frozen Model](https://www.tensorflow.org/mobile/prepare_models#how_do_you_get_a_model_you_can_use_on_mobile) or [TensorFlow Hub module](https://www.tensorflow.org/hub/) to a web-friendly format | ||
@@ -79,3 +79,15 @@ 1. Install the TensorFlow.js pip package: | ||
tf.keras SavedModel model example: | ||
```bash | ||
$ tensorflowjs_converter \ | ||
--input_format=keras_saved_model \ | ||
/tmp/my_tf_keras_saved_model/1542211770 \ | ||
/tmp/my_tfjs_model | ||
``` | ||
Note that the input path used above is a subfolder that has a Unix epoch | ||
time (1542211770) and is generated automatically by tensorflow when it | ||
saved a tf.keras model in the SavedModel format. | ||
|Positional Arguments | Description | | ||
@@ -82,0 +94,0 @@ |---|---| |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2849906
175
17697
288