@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.tensorflow.framework.NodeDef)) { return super.equals(obj); } org.tensorflow.framework.NodeDef other = (org.tensorflow.framework.NodeDef) obj; boolean result = true; result = result && getName() .equals(other.getName()); result = result && getOp() .equals(other.getOp()); result = result && getInputList() .equals(other.getInputList()); result = result && getDevice() .equals(other.getDevice()); result = result && internalGetAttr().equals( other.internalGetAttr()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + OP_FIELD_NUMBER; hash = (53 * hash) + getOp().hashCode(); if (getInputCount() > 0) { hash = (37 * hash) + INPUT_FIELD_NUMBER; hash = (53 * hash) + getInputList().hashCode(); } hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); if (!internalGetAttr().getMap().isEmpty()) { hash = (37 * hash) + ATTR_FIELD_NUMBER; hash = (53 * hash) + internalGetAttr().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
size += 1 * getInputList().size();
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.tensorflow.framework.NodeDef)) { return super.equals(obj); } org.tensorflow.framework.NodeDef other = (org.tensorflow.framework.NodeDef) obj; boolean result = true; result = result && getName() .equals(other.getName()); result = result && getOp() .equals(other.getOp()); result = result && getInputList() .equals(other.getInputList()); result = result && getDevice() .equals(other.getDevice()); result = result && internalGetAttr().equals( other.internalGetAttr()); result = result && unknownFields.equals(other.unknownFields); return result; }
size += 1 * getInputList().size();
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + OP_FIELD_NUMBER; hash = (53 * hash) + getOp().hashCode(); if (getInputCount() > 0) { hash = (37 * hash) + INPUT_FIELD_NUMBER; hash = (53 * hash) + getInputList().hashCode(); } hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); if (!internalGetAttr().getMap().isEmpty()) { hash = (37 * hash) + ATTR_FIELD_NUMBER; hash = (53 * hash) + internalGetAttr().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Procedure(value = "load.tensorflow", mode = Mode.WRITE) public Stream<LoadResult> loadTensorFlow(@Name("file") String url) throws IOException { GraphDef graphDef = GraphDef.parseFrom(new BufferedInputStream(new URL(url).openStream())); Map<String, Node> nodes = new HashMap<>(); // tod model node, layer nodes for (NodeDef nodeDef : graphDef.getNodeList()) { Node node = db.createNode(Types.Neuron); node.setProperty("name", nodeDef.getName()); if (nodeDef.getDevice() != null) node.setProperty("device", nodeDef.getDevice()); node.setProperty("op", nodeDef.getOp()); nodeDef.getAttrMap().forEach((k, v) -> { Object value = getValue(v); if (value != null) { node.setProperty(k, value); } }); nodes.put(nodeDef.getName(), node); } long rels = 0; for (NodeDef nodeDef : graphDef.getNodeList()) { Node target = nodes.get(nodeDef.getName()); nodeDef.getInputList().forEach(name -> nodes.get(name).createRelationshipTo(target, RelTypes.INPUT)); // todo weights rels += nodeDef.getInputCount(); } return Stream.of(new LoadResult(url,"tensorflow",nodes.size(), rels)); }