mirror of
https://github.com/wassname/keras-js.git
synced 2026-09-10 12:15:12 +08:00
update Model class
This commit is contained in:
@@ -10,6 +10,7 @@ export default class Input extends Layer {
|
||||
*/
|
||||
constructor (attrs = {}) {
|
||||
super(attrs)
|
||||
this.layerClass = 'Input'
|
||||
|
||||
const {
|
||||
shape = []
|
||||
|
||||
+2
-1
@@ -283,7 +283,8 @@ export default class Model {
|
||||
if (inboundLayers.length !== 1) {
|
||||
throw new Error(`Layer name ${currentLayer.name} has ${inboundLayers.length} inbound nodes, but is not a Merge layer.`)
|
||||
}
|
||||
currentLayer.result = currentLayer.call(new Tensor(inboundLayers[0].result.tensor.data, inboundLayers[0].result.tensor.shape, { gpu: this.gpu }))
|
||||
const prevLayerResult = inboundLayers[0].result
|
||||
currentLayer.result = currentLayer.call(new Tensor(prevLayerResult.tensor.data, prevLayerResult.tensor.shape, { gpu: this.gpu }))
|
||||
}
|
||||
currentLayer.hasResult = true
|
||||
}
|
||||
|
||||
+1
-3
@@ -20,11 +20,9 @@ export default class Tensor {
|
||||
constructor (data, shape, options = {}) {
|
||||
this._type = options.type || Float32Array
|
||||
|
||||
if (data && data.length && data instanceof this._type) {
|
||||
if (data && data.length && (data instanceof this._type || data instanceof Array)) {
|
||||
checkShape(data, shape)
|
||||
this.tensor = ndarray(data, shape)
|
||||
} else if (data && data.length && data instanceof Array) {
|
||||
checkShape(data, shape)
|
||||
this.tensor = ndarray(new this._type(data), shape)
|
||||
} else if (!data.length && shape.length) {
|
||||
// if shape present but data not provided, initialize with 0s
|
||||
|
||||
Reference in New Issue
Block a user