UNPKG

@ai-on-browser/data-analysis-models

Version:

Data analysis model package without any dependencies

36 lines (30 loc) 550 B
import Layer from './base.js' import Tensor from '../../../util/tensor.js' /** * Constant layer */ export default class ConstLayer extends Layer { /** * @param {object} config object * @param {number} config.value Value */ constructor({ value, ...rest }) { super(rest) this._value = value } calc() { const ten = Tensor.fromArray(this._value) if (ten.dimension === 2) { return ten.toMatrix() } return ten } grad() {} toObject() { return { type: 'const', value: this._value, } } } ConstLayer.registLayer()