AttributeError: 'Cycler' object has no attribute 'by_key' when python3 mnist_1.0_softmax.py #10

Closed
bigwhite opened this Issue Jan 23, 2017 · 8 comments

Projects

None yet

5 participants

@bigwhite

I met a problem when running the training. My environment is below:

ubuntu 16.04.1
git version 2.7.4
python3-matplotlib  :1.5.1-1ubuntu1
python3-pip: 8.1.1-2ubuntu0.4

$ pip3 install --upgrade tensorflow
Collecting tensorflow
  Downloading tensorflow-0.12.1-cp35-cp35m-manylinux1_x86_64.whl (43.1MB)
    100% |████████████████████████████████| 43.1MB 46kB/s
Collecting numpy>=1.11.0 (from tensorflow)
  Downloading numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl (16.8MB)
    100% |████████████████████████████████| 16.8MB 111kB/s
Collecting six>=1.10.0 (from tensorflow)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting wheel>=0.26 (from tensorflow)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 1.3MB/s
Collecting protobuf>=3.1.0 (from tensorflow)
  Downloading protobuf-3.1.0.post1-py2.py3-none-any.whl (347kB)
    100% |████████████████████████████████| 348kB 1.1MB/s
Collecting setuptools (from protobuf>=3.1.0->tensorflow)
  Downloading setuptools-33.1.1-py2.py3-none-any.whl (472kB)
    100% |████████████████████████████████| 481kB 1.1MB/s
Installing collected packages: numpy, six, wheel, setuptools, protobuf, tensorflow
Successfully installed numpy-1.11.0 protobuf setuptools-20.7.0 six-1.10.0 tensorflow wheel-0.29.0

the latest commit of my local copy for this tutorial is “commit a9eb2bf”.

The error log is :

$ python3 mnist_1.0_softmax.py
/usr/lib/python3/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
/usr/lib/python3/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')


Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "mnist_1.0_softmax.py", line 80, in <module>
    datavis = tensorflowvisu.MnistDataVis()
  File "/home/tonybai/test/tensorflow/tensorflow-mnist-tutorial/tensorflowvisu.py", line 166, in __init__
    self._color4 = self.__get_histogram_cyclecolor(histogram4colornum)
  File "/home/tonybai/test/tensorflow/tensorflow-mnist-tutorial/tensorflowvisu.py", line 160, in __get_histogram_cyclecolor
    colors = clist.by_key()['color']
AttributeError: 'Cycler' object has no attribute 'by_key'

@showforj

请问这个问题 怎么解决了

@bigwhite

@showforj I have commented the __get_histogram_cyclecolor invoking in init and do some hard coding to self._color4 and self._color5:

def __init__(self, title1=None, title2=None, title3=None, title4=None, title5=None, title6=None, histogram4colornum=None, histogram5colornum=None, dpi=70):
        #self._color4 = self.__get_histogram_cyclecolor(histogram4colornum)
        #self._color5 = self.__get_histogram_cyclecolor(histogram5colornum)
        self._color4 = '#CFF57F'
        self._color5 = '#E6C54A'
@alfonsoeromero

I had the same problem, but I upgraded matplotlib to the last version via pip and it seems to work.

@martin-gorner
Owner

Try to upgrade matplotlib:
pip3 install --upgrade matplotlib

@martin-gorner
Owner

The reason is that on Linux, you need to install matplotlib with apt-get because that also pulls in the graphics backend on which matplotlib relies.
But unfortunately, the version of martplotlib you get is not the freshest.

@bigwhite
bigwhite commented Feb 6, 2017

after upgrading the matplotlib according to @martin-gorner advice, the problem disappeared:

$ pip3 install --upgrade matplotlib
Collecting matplotlib
  Downloading matplotlib-2.0.0-1-cp35-cp35m-manylinux1_x86_64.whl (14.7MB)
    100% |████████████████████████████████| 14.7MB 100kB/s
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting six>=1.10 (from matplotlib)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting python-dateutil (from matplotlib)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 322kB/s
Collecting numpy>=1.7.1 (from matplotlib)
  Using cached numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
Collecting pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 484kB/s
Collecting pytz (from matplotlib)
  Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
    100% |████████████████████████████████| 491kB 303kB/s
Installing collected packages: six, cycler, python-dateutil, numpy, pyparsing, pytz, matplotlib
Successfully installed cycler-0.10.0 matplotlib-2.0.0 numpy-1.12.0 pyparsing-2.1.10 python-dateutil-2.6.0 pytz-2016.10 six-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
@bigwhite bigwhite closed this Feb 6, 2017
@bigwhite
bigwhite commented Feb 6, 2017

@martin-gorner I suggest that It is better to put the "matplotlib upgrade" step into INSTALL.txt.

@gpussetto

Problem fixed by updating matplotlib as per martin-gorner sugestion. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment