简体   繁体   English

在尝试训练模型时,我遇到ValueError:使用序列设置数组元素

[英]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.

相关问题 我正在制定梯度下降算法。 功能,我不断收到 ValueError 说明 ValueError: setting an array element with a sequence - I am formulating a gradient dexcent algo. fuction and I keep getting a ValueError stating ValueError: setting an array element with a sequence DQN 模型值错误:使用序列设置数组元素 - DQN Model ValueError: setting an array element with a sequence 使用Scipy.optimization的蛮干功能时,为什么会出现“ ValueError:设置具有序列的数组元素”的问题? - Why am I getting “ValueError: setting an array element with a sequence.” when using the brute function from Scipy.optimization? x_train = x_train.astype('float64') ValueError: setting an array element with a sequence - x_train = x_train.astype('float64') ValueError: setting an array element with a sequence ValueError:尝试存储图像HoG功能时,使用序列设置数组元素 - ValueError: setting an array element with a sequence while trying to store image HoG features 将来自 dataframe 的样本输入到 ARMA model 并得到“ValueError:设置具有序列的数组元素”。 - Inputing samples from a dataframe into an ARMA model and getting 'ValueError: setting an array element with a sequence.' ValueError:使用序列设置数组元素? - ValueError: setting an array element with a sequence? __ValueError:使用序列设置数组元素 - __ValueError: setting an array element with a sequence ValueError:使用序列设置数组元素 - ValueError:setting an array element with a sequence ValueError:使用序列设置数组元素 - ValueError: Setting an array element with sequence
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM