Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing elements must be in increasing order #1

Open
minghigh opened this issue Apr 23, 2017 · 7 comments
Open

Indexing elements must be in increasing order #1

minghigh opened this issue Apr 23, 2017 · 7 comments

Comments

@minghigh
Copy link

minghigh commented Apr 23, 2017

when I run the following code (demo.mp3 is my example music)

python acapellabot.py demo.mp3

got errors :

Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 85, in select
    int(a)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "acapellabot.py", line 148, in <module>
    acapellabot.loadWeights(args.weights)
  File "acapellabot.py", line 88, in loadWeights
    self.model.load_weights(path)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2500, in load_weights
    load_weights_from_hdf5_group(f, self.layers)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2900, in load_weights_from_hdf5_group
    original_backend)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2841, in preprocess_weights_for_loading
    weights[0] = conv_utils.convert_kernel(weights[0])
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\utils\conv_utils.py", line 86, in convert_kernel
    return np.copy(kernel[slices])
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\_objects.c:2705)
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\_objects.c:2663)
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\dataset.py", line 462, in __getitem__
    selection = sel.select(self.shape, args, dsid=self.id)
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 88, in select
    sel[args]
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 356, in __getitem__
    if sorted(arg) != list(arg):
TypeError: unorderable types: NoneType() < int()

My environment as following:

  1. python : 3.5.2
  2. Tensorflow : 1.1.0
  3. Keras : 2.0.3
  4. librosa : 0.50
  5. h5py : 2.6.0

In Window 10.

@pedrohml
Copy link

Hi there,
I am facing a similar problem when loading weights file:
TypeError: Indexing elements must be in increasing order

This error seems to have the same cause as above.
I am using same libraries set of @minghigh, but running on mac.

@madebyollin
Copy link
Owner

madebyollin commented Apr 23, 2017

Thanks for pointing this out!

The weights were saved from Theano 0.9.0 using the 'tf' dim ordering–it looks like they don't work with the TensorFlow backend (tested on CentOS 7.3 with both TF/Theano installed and the packages you listed; tf backend gives the same unorderable types error, but Theano works).

I'll see if I can figure out a way to make the weights interoperable (assuming that this is some sort of configuration mistake on my end). In the meantime, switching to Theano should hopefully resolve the issue (don't forget to change ~/.keras/keras.json):

{
    "backend": "theano",
    "image_dim_ordering": "tf"
}

@arlose
Copy link

arlose commented Apr 26, 2017

I have the same problem
$ python acapellabot.py test.mp3
Using TensorFlow backend.
('\x1b[33m', 'Model has 668225 params', '\x1b[0m')
('\x1b[33m', "Weights provided; performing inference on ['test.mp3']...", '\x1b[0m')
('\x1b[1m', 'Loading weights', '\x1b[0m')
Traceback (most recent call last):
File "acapellabot.py", line 145, in
acapellabot.loadWeights(args.weights)
File "acapellabot.py", line 88, in loadWeights
self.model.load_weights(path)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2500, in load_weights
load_weights_from_hdf5_group(f, self.layers)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2900, in load_weights_from_hdf5_group
original_backend)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2841, in preprocess_weights_for_loading
weights[0] = conv_utils.convert_kernel(weights[0])
File "/usr/local/lib/python2.7/dist-packages/keras/utils/conv_utils.py", line 86, in convert_kernel
return np.copy(kernel[slices])
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2840)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2798)
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/dataset.py", line 474, in getitem
selection = sel.select(self.shape, args, dsid=self.id)
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/selections.py", line 90, in select
sel[args]
File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/selections.py", line 361, in getitem
raise TypeError("Indexing elements must be in increasing order")
TypeError: Indexing elements must be in increasing order

My environment as following:
ubuntu 14.04
Python 2.7.6
tensorflow (1.0.1)
tensorflow-gpu (1.0.1)
Keras (2.0.3)
h5py (2.7.0)
librosa (0.5.0)

I change the backend to theano but have the new problem:

File "acapellabot.py", line 130, in
acapellabot = AcapellaBot()
File "acapellabot.py", line 30, in init
convA = Conv2D(64, 3, activation='relu', padding='same')(mashup)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 551, in call
self.build(input_shapes[0])
File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 125, in build
raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found None.

@madebyollin
Copy link
Owner

madebyollin commented Apr 26, 2017

@arlose Regarding the "channel dimension of the inputs should be defined. Found None." issue–You're probably using the th dimension ordering; the trained weights were saved in tf ordering. Could you try opening ~/keras/keras.json and specifying tf ordering:

{
    "backend": "theano",
    "image_dim_ordering": "tf"
}

I think there's a way to set the ordering in the script itself, so I'll see if I can do that to save people some trouble in the future.

@madebyollin
Copy link
Owner

@arlose Also, are you running python 3? From the printout it looks like you're using python 2, but it won't work in python 2 without some adjustments (the issue you're getting there is because of the change in behavior of the division operator, you could probably fix it with some calls to round())

@arlose
Copy link

arlose commented Apr 26, 2017

@madebyollin thanks
i just resolved it

@madebyollin madebyollin changed the title Can not run Indexing elements must be in increasing order Apr 26, 2017
@mktanguturi
Copy link

Hi @madebyollin ,
Is this issue resolved with Tensorflow backend? Or still we need to use Theano backend?

Kindly confirm.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants