Code Monkey home page Code Monkey logo

Comments (17)

lanpa avatar lanpa commented on April 27, 2024

I could not locate the corresponding code in your error message in newest (the version on github) tensorboardX . Which version are you on?

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I use pip3 install tensorboardX, which version is 0.8. I will update it later.

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

The pip version is pretty old. XD
Please try pip install git+https://github.com/lanpa/tensorboard-pytorch if you have time~

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I upgrade the version from 0.8 to 0.9. But the problem still exist.

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

So what is the error message in V0.9?

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

same as V0.8. Given as follows, where fun_wr is my wrapper class to write summary.
File "/tchelpers.py", line 346, in write
fun_wr(mn0,data[mn0], niter)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/writer.py", line 323, in add_histogram
self.file_writer.add_summary(histogram(tag, values, bins), global_step)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/summary.py", line 114, in histogram
hist = make_histogram(values.astype(float), bins)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/summary.py", line 132, in make_histogram
bucket=counts)
TypeError: 0 has type numpy.int64, but expected one of: int, long, float

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I will try to debug it later if my training machine is free...

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

Hi, what is the output of type(mn0), type(data[mn0]).
(a small example to produce the bug will be great help)

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I will provide sample data to you later because my machine is not free...

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

The attached is my data (numpy *.npz file in zip file) to be used in the function "make_histogram" in the summary.py.

The error arises in the last para of "HistogramProto" function, which is bucket=counts.

I hope this will help you to debug the program.

data.zip

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

no error on my machine :(

import numpy as np
from tensorboardX import SummaryWriter

data = np.load('test.npz')
bins = data['bins']
data = data['values']
print(data.shape)
with SummaryWriter() as w:
    w.add_histogram('data', data, 0, bins=bins)
    w.add_histogram('data', data, 1)
    

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I use the code above but the error is still there. The error msg is same as the before.
Is this due to the version of numpy? My numpy version is 1.13.0.

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

I debug it again and again. I found that error arose in
HistogramProto(min=values.min(),max=values.max(), num=len(values),sum=values.sum(),sum_squares=sum_sq,bucket_limit=limits,bucket=counts).

because the type of counts is np.int64 array where is given by

counts, limits = np.histogram(values, bins=bins) in summary.py.

If I replace counts with a list, such as [1,2], everything is ok.

or use as
HistogramProto(min=values.min(),max=values.max(), num=len(values),sum=values.sum(),sum_squares=sum_sq,bucket_limit=limits,bucket=counts.tolist()) is ok.

It seems that my numpy can not automatically convert an numpy array to list of ints.

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

Hi, my counts.dtype is also numpy.int64. Based on your description, it looks like the protobuf does not convert ndarray to the datatype it expect. Btw, have you run demo.py before? Did it break the code? Thanks

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

If use demo.py, got the same error as follows

Traceback (most recent call last):
File "demo.py", line 35, in
writer.add_histogram(name, param, n_iter)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/writer.py", line 323, in add_histogram
self.file_writer.add_summary(histogram(tag, values, bins), global_step)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/summary.py", line 114, in histogram
hist = make_histogram(values.astype(float), bins)
File "/opt/pytorch/lib/python3.5/site-packages/tensorboardX/summary.py", line 132, in make_histogram
bucket=counts)
TypeError: 0 has type numpy.int64, but expected one of: int, long, float
Exception ignored in: <function WeakValueDictionary.init..remove at 0x7f6f077a5378>
Traceback (most recent call last):
File "/opt/pytorch/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

from tensorboardx.

jyzhang-bjtu avatar jyzhang-bjtu commented on April 27, 2024

After I upgraded the protobuf from 3.0.0 (in debian distribution) to the latest version (3.5.0), everything is ok.

from tensorboardx.

lanpa avatar lanpa commented on April 27, 2024

I reproduced it on a VM and I found that the minimum working version is 3.2.0. Thanks!

from tensorboardx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.