本文整理匯總了TypeScript中@tensorflow/tfjs.layers.activation方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript layers.activation方法的具體用法?TypeScript layers.activation怎麽用?TypeScript layers.activation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@tensorflow/tfjs.layers
的用法示例。
在下文中一共展示了layers.activation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: resnet
function resnet(x: tf.SymbolicTensor, init: any): tf.SymbolicTensor {
const depth = 8
const width = 32
for (var i = 0; i < depth; ++i) {
let y: tf.SymbolicTensor
if (i != 0)
y = tf.layers.activation({ activation: 'tanh' }).apply(x) as tf.SymbolicTensor
else
y = x
y = tf.layers.dense({ units: width, kernelInitializer: init, activation: 'tanh' }).apply(x) as tf.SymbolicTensor
let x_ = x
if (x_.shape[1] != width)
x_ = tf.layers.dense({ units: width, kernelInitializer: init }).apply(x_) as tf.SymbolicTensor
x = tf.layers.add().apply([x_, y]) as tf.SymbolicTensor
}
x = tf.layers.activation({ activation: 'tanh' }).apply(x) as tf.SymbolicTensor
return x
}