Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: unhashable type: 'numpy.ndarray' Tensorflow

I'm working on adapting one of the MNIST tensorflow tutorials, and I receive this TypeError. According to this question you have to use a placeholder in the dictionary key because numpy arrays are mutable. I believe I'm doing that, but I'm still receiving this error.

# Network Parameters
n_input = 44100 # length of FFT
n_classes = 6 # 6 instrument classes
dropout = 0.75 # Dropout, probability to keep units

# TF Graph input
x = tf.placeholder(tf.float32, [None, n_input])
y = tf.placeholder(tf.float32, [None, n_classes])
keep_prob = tf.placeholder(tf.float32)

I fill up my batches and then pass them to the session.

for file_name in os.listdir('./Input_FFTs'):
    if file_name.endswith('.txt'):
        path = './Input_FFTs/' + file_name
        y, x = getData(path)
        batch_ys[count] = y
        batch_xs[count] = x
        count += 1
sess.run(optimizer, feed_dict={x: batch_xs, y: batch_ys,
                                   keep_prob: dropout})

When I print and check the sizes of batch_xs and batch_ys, they are [batch_size, 44100] and [batch_size, 6] with the correct data. These match the expected sizes of the x and y placeholders.

Can anyone tell me what the problem may be?

Thank you!

like image 651
Ian Marci Avatar asked Aug 13 '26 23:08

Ian Marci


1 Answers

Be very careful about your variable names!

I was replacing my placeholders x, y with arrays x, and y in my loops to fill my train and test patches.

like image 186
Ian Marci Avatar answered Aug 16 '26 14:08

Ian Marci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!