[英]While trying to train the model I am getting ValueError: setting an array element with a sequence
Here is the code. 这是代码。
While trying to run this file, I am getting ValueError: setting an array element with a sequence. 尝试运行此文件时,出现ValueError:设置具有序列的数组元素。
ValueError: setting an array element with a sequence.
I am using tensorflow 1.9 我正在使用tensorflow 1.9
https://github.com/satyenrajpal/Concrete-Crack-Detection/blob/master/Train_CD.py https://github.com/satyenrajpal/Concrete-Crack-Detection/blob/master/Train_CD.py
Here is the code I am trying to run. 这是我要运行的代码。
AFAIK this problem usually arises from having a one or more entries in your array that is not the same length as the rest, so essentially the array isn't seen as a valid matrix, but rather a 'sequence' of arrays that differ in length. AFAIK此问题通常是由于数组中一个或多个条目的长度与其余字段的长度不同而引起的,因此从本质上讲,该数组不被视为有效矩阵,而是长度不同的数组的“序列” 。
Try debugging the code and making sure that all the elements of your array are the same shape, I haven't looked through all your code, so I'm not sure if you intentionally want to feed sequences to your model, but in that case you should look into padding your data before inputting it, so that all the elements in your array are of the same length. 尝试调试代码,并确保数组的所有元素都具有相同的形状,但我没有仔细检查所有代码,因此不确定是否有意向模型提供序列,但是在这种情况下您应该在输入数据之前先对数据进行填充,以使数组中的所有元素都具有相同的长度。
There are ample options for doing something like this, can't list them all off the top of my head, but one that comes to mind, that I've personally used before is tf.keras.preprocessing.sequence.pad_sequences (that links to API v1.6, but it's also available in v1.11, just checked now) 有很多选项可以执行这样的操作,无法一一列出,但我想到的一个是我以前亲自使用过的tf.keras.preprocessing.sequence.pad_sequences (该链接API v1.6,但在v1.11中也可用,请立即检查)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.