Comments (8)
your solution works, but that shouldn't make any difference lol
from tensorboardx.
Passing the variable directly to the model solved the problem. But I don't know why. XD
Does this bug happen only in v0.2?
import torch
import torch.nn as nn
from torch.autograd import Variable
from datetime import datetime
from tensorboard import SummaryWriter
model = nn.Linear(10, 10)
h = model(Variable(torch.rand(10, 10), requires_grad=True))
writer = SummaryWriter('runs/'+datetime.now().strftime('%B%d %H:%M:%S'))
writer.add_graph(model, h)
writer.close()
from tensorboardx.
in theory it shouldn't be possible to add a graph in v0.1.12, right?
I tried with a nn.Sequential model and the result was the same.
from tensorboardx.
If your 0.1.12 is installed via pip then this function wont work. But if you build by yourself (0.1.12+xxxx) then it should work. Have you tried my solution?
from tensorboardx.
I found something..
if you write
x = Variable(torch.rand(10, 10), requires_grad=True)
model = nn.Linear(10, 10)
h = model(x)
writer = SummaryWriter('runs/'+datetime.now().strftime('%B%d %H:%M:%S'))
writer.add_graph(model,h)
writer.close()
and check using the debug the lastVar.grad_fn.next_functions
you will find the weight,the bias (as expected) but also the input, filled with the variable
field, holding the matrix.
If you write
#x = Variable(torch.rand(10, 10), requires_grad=True)
model = nn.Linear(10, 10)
#h = model(x)
writer = SummaryWriter('runs/'+datetime.now().strftime('%B%d %H:%M:%S'))
writer.add_graph(model,model(Variable(torch.rand(10, 10), requires_grad=True)))
writer.close()
The input is still an element of the tuple, but it has a variable
field empty.Since we create a binding dict id2name
with the id of the Parameters of the network, the input is not included. As such, in the first case the input is still evaluated in the make_name
function as it hold the variable
field, but there is no association with its id, producing the above error.
An easy way to fix it would be to check before insert using the id from id2name
in the function make_name
from tensorboardx.
I update my pytorch to version 0.3, but I got the same error after my update. Previously there is no problem. Here is my code:
output_sample = model(Variable(torch.Tensor(1, 2, patch_size, patch_size).type(dtype), requires_grad=True), Variable(torch.Tensor(1, 1, patch_size, patch_size).type(dtype), requires_grad=True))
writer = SummaryWriter()
writer.add_graph(model, output_sample)
Even using the simple code I still get the error:
model = nn.Linear(10, 10)
h = model(Variable(torch.rand(10, 10), requires_grad=True))
writer = SummaryWriter()
writer.add_graph(model, h)
writer.close()
from tensorboardx.
That's expected behavior on v0.3. Please have a try on the onnx version: https://github.com/lanpa/tensorboard-pytorch/blob/master/onnx_graph.py
(you may need to install onnx as well)
from tensorboardx.
Since v0.2 is legacy, closing this.
from tensorboardx.
Related Issues (20)
- tensorboardX is incompatible with protobuf 4.21.0 HOT 16
- draw NaN with triangle
- Subsequent hparams missing HOT 4
- DeprecationWarning: crc32c.crc32 will be eventually removed, use crc32c.crc32c instead HOT 2
- AttributeError: 'NoneType' object has no attribute 'get_logdir' HOT 3
- Protobuf version HOT 4
- How can I connect previous log file into new one in tensorboard HOT 1
- How can i read tensorboard by python ? HOT 2
- Deprecation Warnings HOT 15
- OSS License compatibility question
- Remove upper pins on protobuf HOT 4
- tensorboardX is converting white/blank space and other non alphanumeric characters to underscore
- Update unittests for newer protobuf
- Possibility of v2.5.2 with upper pin on protobuf of <4? HOT 3
- The license_file parameter is deprecated HOT 3
- Loosening protobuf version limit breaking downstream packages HOT 7
- Is there an efficient way to log line plots? HOT 5
- EOFError multiprocessing HOT 1
- Set experiment name when using CometML HOT 1
- Support add_mesh for visdom writer?
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 tensorboardx.