How to feed multiple "LIST" inputs through feed_dict in tensorflow

Viewed 484

I do have to inputs as following:

input_t = []
input_z = []
for j in range(batch_size):      
    input_t.append(train_data[train_batch_order[j + i * batch_size], :, :, :])  
    input_z.append(Gtrain_data['input'[train_Gbatch_order[j + i*batch_size], :, :, :])     
input_t = np.array(input_t)
batch_z= np.array(input_z)`

Now, I want to run the optimizer as following:

_ = sess.run(g_opt, feed_dict={input_images: input_t, input_z: batch_z, lr_G: learning_rate_G})

But I get the unhashable type: 'list'.
So, how can I feed multiple "LIST" inputs through feed_dict in tensorflow??

1 Answers

Only hashable objects can be dictionary keys. So lists can not while tuples can.

I'm not 100% sure but probably you wanted to create feed_dict like this:

feed_dict = {'input_images': input_t, 'input_z': batch_z, 'lr_G': learning_rate_G}

Here keys are strings that is names for values. For example, name 'input_images' for variable input_t which is numpy array according to the line input_t = np.array(input_t). That is how dictionaries are used most of the time - to create mapping between names (keys) and variables (values).

Related