I am trying to implement a simple logistic regression model prepared using my own set of images, but I get this error when I try to train the model:
Traceback (most recent call last): File "main.py", line 26, in <module> model.entrenar_modelo(sess, training_images, training_labels) File "/home/jr/Desktop/Dropbox/Machine_Learning/TF/Míos/Hip/model_log_reg.py", line 24, in entrenar_modelo train_step.run({x: batch_xs, y_: batch_ys}) File "/home/jr/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1267, in run _run_using_default_session(self, feed_dict, self.graph, session) File "/home/jr/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2763, in _run_using_default_session session.run(operation, feed_dict) File "/home/jr/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 334, in run np_val = np.array(subfeed_val, dtype=subfeed_t.dtype.as_numpy_dtype) ValueError: setting an array element with a sequence.
The data I submit to train_step.run({x: batch_xs, y_: batch_ys}) looks like this:
- batch_xs: list of tensor objects representing 100x100 images (10,000 long tensors)
- batch_ys: tag list as float (1.0 or 0.0)
What am I doing wrong? thanks in advance!
EDIT 1 : the problem is that I had to evaluate the tensors in batch_xs before passing them to train_step.run(...) . I thought the run method would take care of this, but I think I was wrong? Anyway, as soon as I did this before calling the function:
for i, x in enumerate(batch_xs): batch_xs[i] = x.eval()
EDIT 2 . I had several problems even after it was suggested in the answers below. I finally fixed everything by breaking tensors and using numpy arrays.
Hope this helps someone else.
mathetes
source share