Comments (6)
Hello,
You have to change the following :
_optimize_trace
to _optimize_graph
in pytorch_builder.py
line 71
I will if there is no pull request make one to fix this little bug
Hope it helps!
from hiddenlayer.
Hello, I have made this change manually in pytorch_builder.py
but now get the below
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in <cell line: 11>()
9 # see:#100
10 # Jupyter Notebook renders it automatically
---> 11 hl.build_graph(model_resnet, torch.zeros([4,3,256,256]).to(device))
2 frames
/usr/local/lib/python3.10/dist-packages/hiddenlayer/pytorch_builder.py in (.0)
80 op = torch_node.kind()
81 # Parameters
---> 82 params = {k: torch_node[k] for k in torch_node.attributeNames()}
83 # Inputs/outputs
84 # TODO: inputs = [i.unique() for i in node.inputs()]
TypeError: 'torch._C.Node' object is not subscriptable`
from hiddenlayer.
You need to hack more.
try:
params = {k: torch_node[k] for k in torch_node.attributeNames()}
except Exception:
params = {}
If you follow various old tutorials with Jupyther notebooks you might need to change stuff like
hl.build_graph(model,torch.zeros([1]))
to
hl.build_graph(model,torch.zeros([1])).build_dot()
Hello, I have made this change manually in
pytorch_builder.py
but now get the below`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in <cell line: 11>() 9 # see:#100 10 # Jupyter Notebook renders it automatically ---> 11 hl.build_graph(model_resnet, torch.zeros([4,3,256,256]).to(device))
2 frames
/usr/local/lib/python3.10/dist-packages/hiddenlayer/pytorch_builder.py in (.0) 80 op = torch_node.kind() 81 # Parameters ---> 82 params = {k: torch_node[k] for k in torch_node.attributeNames()} 83 # Inputs/outputs 84 # TODO: inputs = [i.unique() for i in node.inputs()]
TypeError: 'torch._C.Node' object is not subscriptable`
from hiddenlayer.
While that works, it also loses kernel size information from parameters to be included in the graph. Alternatively, you can follow the error and change __getitem__
to _node_get
. To do that, include the following in the beginning of your pytorch_builder.py
# From https://github.com/pytorch/pytorch/blob/2efe4d809fdc94501fc38bf429e9a8d4205b51b6/torch/utils/tensorboard/_pytorch_graph.py#L384
def _node_get(node: torch._C.Node, key: str):
"""Gets attributes of a node which is polymorphic over return type."""
sel = node.kindOf(key)
return getattr(node, sel)(key)
torch._C.Node.__getitem__ = _node_get
Now, you should be able to extract from the nodes just fine, so there should be no issues with this line.
params = {k: torch_node[k] for k in torch_node.attributeNames()}
Credit: TypeError: 'torch._C.Node' object is not subscriptable
from hiddenlayer.
+1 with the same problem
from hiddenlayer.
Related Issues (20)
- torch._C.Node' object is not subscriptable
- module 'torch.jit' has no attribute '_get_trace_graph' HOT 3
- Pytorch Model Branch Duplication
- AttributeError: module 'torch.jit' has no attribute '_get_trace_graph' HOT 3
- ONNX symbolic expected a constant value of the rand argument
- tensor shapes not displayed in rendered graph HOT 5
- can it show variable name at every node?
- demo pytorch_graph.ipynb not working
- How to display branch nodes / parallel blocks HOT 2
- Not displaying graph as expected in Jupyter Notebook (either during training or after training) HOT 1
- How exactly should look the second parametr?
- build_graph() does not return HOT 2
- AttributeError: 'Digraph' object has no attribute '_repr_svg_' HOT 2
- How to display dimensions and change font to Times HOT 1
- TypeError for Pytorch Model HOT 4
- support yolov5 HOT 2
- Error when trying to print the Model
- Error while trying to run the example
- How to plot bert model? (Transfomer models) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hiddenlayer.