1

for a deep learning project, before running my model on all my data I want to test it on artificial data. So I tried to create some data but I have a dimension problem.

# Here, we create dummy data as an example
num_frames = 12
num_examples = 10000


input_court_array = np.random.rand(num_examples, num_frames, 8)
input_poses_array = np.random.rand(num_examples, num_frames, 48)
input_shuttle_array = np.random.rand(num_examples, num_frames, 2)
labels_array = np.random.randint(2, size=(num_examples,))

# Sliding window approach 
stride = 1

input_court_examples = []
input_poses_examples = []
input_shuttle_examples = []
labels_examples = []

for i in range(0, len(input_court_array) - num_frames + 1, stride):
    input_court_example = input_court_array[i:i+num_frames]
    input_poses_example = input_poses_array[i:i+num_frames]
    input_shuttle_example = input_shuttle_array[i:i+num_frames]
    labels_example = labels_array[i+num_frames-1]
    
    input_court_examples.append(input_court_example)
    input_poses_examples.append(input_poses_example)
    input_shuttle_examples.append(input_shuttle_example)
    labels_examples.append(labels_example)


input_court_examples = np.array(input_court_examples)
input_poses_examples = np.array(input_poses_examples)
input_shuttle_examples = np.array(input_shuttle_examples)
labels_examples = np.array(labels_examples)

print("Dimensions des données générées :")
print("input_court_examples :", input_court_examples.shape)
print("input_poses_examples :", input_poses_examples.shape)
print("input_shuttle_examples :", input_shuttle_examples.shape)
print("labels_examples :", labels_examples.shape)

I have the following output :

Dimensions des données générées :
input_court_examples : (9989, 12, 12, 8)
input_poses_examples : (9989, 12, 12, 48)
input_shuttle_examples : (9989, 12, 12, 2)
labels_examples : (9989,)

Whereas i would like to have :

Dimensions des données générées :
input_court_examples : (9989, 12, 8)
input_poses_examples : (9989, 12, 48)
input_shuttle_examples : (9989, 12, 2)
labels_examples : (9989,)

I tried to modifie my for loop like that :

for i in range(0, len(input_court_array) - num_frames + 1, stride):
input_court_example = input_court_array\[i:i+num_frames, :, :\]
input_poses_example = input_poses_array\[i:i+num_frames, :, :\]
input_shuttle_example = input_shuttle_array\[i:i+num_frames, :, :\]
labels_example = labels_array\[i:i+num_frames, :\]

    input_court_examples.append(input_court_example)
    input_poses_examples.append(input_poses_example)
    input_shuttle_examples.append(input_shuttle_example)
    labels_examples.append(labels_example)

But it didn't work

What may be the problem?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Baptiste G
  • 11
  • 4
  • Why you do the sliding window approach if your generated data have already the right shape? I mean each time you slice `input_court_array[i:i+num_frames]` you get a `(12,12,8)` array, which already has the extra `12 = num_frames` dimension... I don't understand what are you trying to achieve – Luca Anzalone Jun 13 '23 at 18:46
  • yes you are right i don't need to do this, thanks ! – Baptiste G Jun 15 '23 at 08:58

0 Answers0