0

my data format is like this: enter image description here

and I use the data to feed my tensorflow code:

user_batch = tf.placeholder(tf.int32, shape=[None], name="id_user")
item_batch = tf.placeholder(tf.int32, shape=[None], name="id_item")
tag_batch = tf.placeholder(tf.int32,shape=[3,None],name ="id_tag")
rate_batch = tf.placeholder(tf.float32, shape=[None])

and

for i in range(EPOCH_MAX * samples_per_batch):
    users, items,tags,rates = next(iter_train)            
    _, pred_batch = sess.run([train_op, infer], feed_dict={user_batch: users,
                                                           item_batch: items,
                                                           tag_batch:tags,
                                                           rate_batch: rates})`

then it has valueError:

File "/home/ljh/NCF_TF/GMF.py", line 125, in GMF rate_batch: rates}) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 766, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 937, in _run np_val = np.asarray(subfeed_val, dtype=subfeed_dtype) File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py",line 531, in asarray return array(a, dtype, copy=False, order=order) ValueError: setting an array element with a sequence.

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
Joyee
  • 31
  • 1
  • 4
  • Possible duplicate of [ValueError: setting an array element with a sequence](https://stackoverflow.com/questions/4674473/valueerror-setting-an-array-element-with-a-sequence) – P. Camilleri Jun 07 '17 at 10:40
  • The problem might be `tag_batch = tf.placeholder(tf.int32,shape=[3,None],name ="id_tag")`, where maybe it expects something with shape as `[None, 3]`, a print of type and shapes of `users, items,tags,rates` might be useful – Pietro Tortella Jun 07 '17 at 12:56
  • I have already create the shape,and confirm all the variables'shape is correct.but it still have the same problem@PietroTortella – Joyee Jun 12 '17 at 10:09

0 Answers0