Jelajahi Sumber

Update tf.js

Lutz Roeder 4 tahun lalu
induk
melakukan
196e3d7e81
2 mengubah file dengan 9 tambahan dan 9 penghapusan
  1. 7 7
      source/tf.js
  2. 2 2
      source/view-sidebar.js

+ 7 - 7
source/tf.js

@@ -957,11 +957,7 @@ tf.Attribute = class {
         this._type = null;
         const schema = value && value.metadata ? value.metadata : metadata.attribute(op, name);
         const visible = metadata.visible(op, name);
-        if (Object.prototype.hasOwnProperty.call(value, 'tensor')) {
-            this._type = 'tensor';
-            this._value = new tf.Tensor(value.tensor);
-        }
-        else if (schema && schema.type) {
+        if (schema && schema.type) {
             this._type = schema.type;
         }
         switch (value.value) {
@@ -985,6 +981,11 @@ tf.Attribute = class {
             case 's':
                 this._value = tf.Utility.decodeText(value.s);
                 break;
+            case 'tensor': {
+                this._type = 'tensor';
+                this._value = new tf.Tensor(value.tensor);
+                break;
+            }
             case 'func': {
                 const name = value.func.name;
                 this._type = 'function';
@@ -1023,7 +1024,6 @@ tf.Attribute = class {
                 break;
             }
         }
-
         if (schema) {
             if (Object.prototype.hasOwnProperty.call(schema, 'visible') && !schema.visible) {
                 this._visible = false;
@@ -2385,7 +2385,7 @@ tf.JsonReader = class {
         const value = json[key];
         switch (key) {
             case 'type':
-                message.type = tf.proto.tensorflow.DataType[value];
+                message.type = typeof value === 'number' ? value : tf.proto.tensorflow.DataType[value];
                 break;
             case 'shape':
                 message.shape = tf.JsonReader.decodeTensorShapeProto(value);

+ 2 - 2
source/view-sidebar.js

@@ -291,9 +291,9 @@ sidebar.NodeSidebar = class {
                 }
                 return value ? value.map((item) => item.toString()).join(', ') : '(null)';
             case 'graph':
-                return value ? value.toString() : '(null)';
+                return value ? value.name : '(null)';
             case 'graph[]':
-                return value ? value.map((item) => item.toString()).join(', ') : '(null)';
+                return value ? value.map((graph) => graph.name).join(', ') : '(null)';
             case 'tensor':
                 if (value && value.type && value.type.shape && value.type.shape.dimensions && value.type.shape.dimensions.length == 0) {
                     return value.toString();