@tensorflow/tfjs-layers
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -25,2 +25,4 @@ import { Scalar, Tensor, Tensor1D, Tensor2D } from '@tensorflow/tfjs-core'; | ||
export declare function squeeze(x: Tensor, axis: number): Tensor; | ||
export declare function temporalPadding(x: Tensor, padding?: [number, number]): Tensor; | ||
export declare function spatial2dPadding(x: Tensor, padding?: [[number, number], [number, number]], dataFormat?: DataFormat): Tensor; | ||
export declare function repeat(x: Tensor, n: number): Tensor; | ||
@@ -27,0 +29,0 @@ export declare function flatten(x: Tensor): Tensor; |
@@ -125,2 +125,48 @@ "use strict"; | ||
exports.squeeze = squeeze; | ||
function temporalPadding(x, padding) { | ||
if (ndim(x) !== 3) { | ||
throw new errors_1.ValueError("temporalPadding expects input tensor to be 3-D, but received a " + | ||
(ndim(x) + "-D tensor.")); | ||
} | ||
if (padding == null) { | ||
padding = [1, 1]; | ||
} | ||
if (padding.length !== 2) { | ||
throw new errors_1.ValueError("temporalPadding expects input padding pattern to be a length-2 " + | ||
("array, but received a length-" + padding.length + " array.")); | ||
} | ||
var pattern = [[0, 0], padding, [0, 0]]; | ||
return tfc.pad(x, pattern); | ||
} | ||
exports.temporalPadding = temporalPadding; | ||
function spatial2dPadding(x, padding, dataFormat) { | ||
if (ndim(x) !== 4) { | ||
throw new errors_1.ValueError("temporalPadding expects input tensor to be 4-D, but received a " + | ||
(ndim(x) + "-D tensor.")); | ||
} | ||
if (padding == null) { | ||
padding = [[1, 1], [1, 1]]; | ||
} | ||
if (padding.length !== 2 || padding[0].length !== 2 || | ||
padding[1].length !== 2) { | ||
throw new errors_1.ValueError('spatial2dPadding expects `padding` to be an Array of two Arrays, ' + | ||
'each of which is an Array of two integers.'); | ||
} | ||
if (dataFormat == null) { | ||
dataFormat = common_3.imageDataFormat(); | ||
} | ||
if (dataFormat !== 'channelsLast' && dataFormat !== 'channelsFirst') { | ||
throw new errors_1.ValueError("Unknown data format: " + dataFormat + ". " + | ||
"Supported data formats are 'channelsLast' and 'channelsFirst."); | ||
} | ||
var pattern; | ||
if (dataFormat === 'channelsFirst') { | ||
pattern = [[0, 0], [0, 0], padding[0], padding[1]]; | ||
} | ||
else { | ||
pattern = [[0, 0], padding[0], padding[1], [0, 0]]; | ||
} | ||
return tfc.pad(x, pattern); | ||
} | ||
exports.spatial2dPadding = spatial2dPadding; | ||
function repeat(x, n) { | ||
@@ -127,0 +173,0 @@ if (x.shape.length !== 2) { |
@@ -87,2 +87,3 @@ import { Scalar, Tensor } from '@tensorflow/tfjs-core'; | ||
private _callHook; | ||
private _addedWeightNames; | ||
readonly id: number; | ||
@@ -89,0 +90,0 @@ protected _stateful: boolean; |
@@ -12,2 +12,3 @@ import { Constraint, MaxNormConfig, MinMaxNormConfig, UnitNormConfig } from './constraints'; | ||
import { BatchNormalizationLayerConfig } from './layers/normalization'; | ||
import { ZeroPadding2DLayerConfig } from './layers/padding'; | ||
import { GlobalPooling2DLayerConfig, Pooling1DLayerConfig, Pooling2DLayerConfig } from './layers/pooling'; | ||
@@ -51,2 +52,3 @@ import { GRUCellLayerConfig, GRULayerConfig, LSTMCellLayerConfig, LSTMLayerConfig, RNNCell, RNNLayerConfig, SimpleRNNCellLayerConfig, SimpleRNNLayerConfig, StackedRNNCellsConfig } from './layers/recurrent'; | ||
static batchNormalization(config: BatchNormalizationLayerConfig): Layer; | ||
static zeroPadding2d(config: ZeroPadding2DLayerConfig): Layer; | ||
static avgPooling1d(config: Pooling1DLayerConfig): Layer; | ||
@@ -53,0 +55,0 @@ static avgPooling2d(config: Pooling2DLayerConfig): Layer; |
@@ -21,2 +21,3 @@ "use strict"; | ||
var normalization_1 = require("./layers/normalization"); | ||
var padding_1 = require("./layers/padding"); | ||
var pooling_1 = require("./layers/pooling"); | ||
@@ -135,2 +136,5 @@ var recurrent_1 = require("./layers/recurrent"); | ||
}; | ||
LayerExports.zeroPadding2d = function (config) { | ||
return new padding_1.ZeroPadding2D(config); | ||
}; | ||
LayerExports.avgPooling1d = function (config) { | ||
@@ -394,2 +398,11 @@ return new pooling_1.AvgPooling1D(config); | ||
heading: 'Layers', | ||
subheading: 'Padding', | ||
namespace: 'layers', | ||
useDocsFrom: 'ZeroPadding2D', | ||
configParamIndices: [0] | ||
}) | ||
], LayerExports, "zeroPadding2d", null); | ||
__decorate([ | ||
tfjs_core_1.doc({ | ||
heading: 'Layers', | ||
subheading: 'Pooling', | ||
@@ -396,0 +409,0 @@ namespace: 'layers', |
@@ -189,3 +189,3 @@ "use strict"; | ||
if (this.useBias) { | ||
this.bias = this.addWeight('kernel', [this.filters], types_1.DType.float32, this.biasInitializer, this.biasRegularizer, true, this.biasConstraint); | ||
this.bias = this.addWeight('bias', [this.filters], types_1.DType.float32, this.biasInitializer, this.biasRegularizer, true, this.biasConstraint); | ||
} | ||
@@ -192,0 +192,0 @@ this.inputSpec = |
@@ -45,3 +45,4 @@ "use strict"; | ||
var tsKey = generic_utils.toCamelCase(pythonicKey); | ||
if (generic_utils.SerializableEnumRegistry.contains(pythonicKey)) { | ||
if (generic_utils.SerializableEnumRegistry.contains(pythonicKey) && | ||
(typeof pythonicValue === 'string' || pythonicValue == null)) { | ||
var enumValue = generic_utils.SerializableEnumRegistry.lookup(pythonicKey, pythonicValue); | ||
@@ -99,3 +100,4 @@ if (enumValue != null) { | ||
else { | ||
if (generic_utils.SerializableEnumRegistry.contains(pyKey)) { | ||
if (generic_utils.SerializableEnumRegistry.contains(pyKey) && | ||
(typeof tsValue === 'string' || tsValue == null)) { | ||
var enumString = generic_utils.SerializableEnumRegistry.reverseLookup(pyKey, tsValue); | ||
@@ -102,0 +104,0 @@ pyDict[pyKey] = enumString; |
@@ -1,2 +0,2 @@ | ||
declare const version = "0.2.0"; | ||
declare const version = "0.3.0"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var version = '0.2.0'; | ||
var version = '0.3.0'; | ||
exports.version = version; |
{ | ||
"name": "@tensorflow/tfjs-layers", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "TensorFlow layers API in JavaScript", | ||
@@ -9,3 +9,3 @@ "private": false, | ||
"devDependencies": { | ||
"@tensorflow/tfjs-core": "0.6.0", | ||
"@tensorflow/tfjs-core": "0.6.1", | ||
"@types/jasmine": "~2.5.53", | ||
@@ -47,4 +47,4 @@ "@types/underscore": "^1.8.7", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "0.6.0" | ||
"@tensorflow/tfjs-core": "0.6.1" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
2172262
81
37479