Each dataset[n]
has 100 data samples as list. (n=0,1,2,...,30
)
I tried
train_dataset = [dataset[i][j] for i,j in [range(30), range(100)]]
but there was an error : ValueError: too many values to unpack (expected 2)
How could I assign train_dataset
that has [dataset[0][0], dataset[0][1], ..., dataset[0][100], dataset[1][0], dataset[1][1], ..., dataset[1][100], ..., dataset[30][0], dataset[30][1], ..., dataset[30][100]]
so len(train_dataset)=3000
?
CodePudding user response:
If I got this right, dataset is a matrix, with size 100x30, and you are trying to get a list from it?
If this is the case, you can do:
dataset = [[x for x in range(30)] for j in range(100)]
train_dataset = [dataset[i][j] for i in range(100) for j in range(30)]
print(train_dataset)
print(len(train_dataset))
dataset will be:
[0, ..., 29]
[0, ..., 29]
x100
[0, ..., 29]
and your output will be:
[0, ..., 29, 0, ..., 29... x100]
resulting an array of size 3000.
CodePudding user response:
for j in range(columns):
for i in range(rows):
train_dataset = dataset[columns][rows]