2

This seems like it should be such an easy thing but I'm having a little trouble figuring out the syntax behind it. Basically, I have this code:

Weights = []
Weights.append(tf.Variable(tf.random_normal( n_input, Population[sample][0]), 0, 1))

It returns the error that an 'int' object is not iterable. However, I can't for the life of me figure out why it's even trying to iterate over an integer.

Any ideas? Thank you!

1
  • Oh my lord, I had a missing parenthesis. Should have been tf.random_normal( (n_input, Population[sample][0]), 0, 1). That way it gives the shape as (n_input, Population[sample][0]). Commented Jun 6, 2016 at 15:36

1 Answer 1

2

The issue in your code comes from tf.random_normal(shape). Here shape should be a list like [n_input, 3].

The error raised is 'int' object is not iterable because Python tries to read n_input as a list, and it is an int.


Your code should be like:

weights = []
weights.append(tf.Variable(tf.random_normal([n_input, Population[sample][0], 0., 1.))
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I was missing a parenthesis and your comment helped me find that

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.