2

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!

2
  • 2
    The x and y you have are the same x and y you got from getData, not tf.placeholder(…). Commented Apr 27, 2017 at 19:16
  • Thanks! I just realized that was the case; it replaced the placeholders. Now I have a different error to deal with, but I understand that one better. Commented Apr 27, 2017 at 19:21

1 Answer 1

12

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.