Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- channels, width, height=200, 1700, 350
- # and out goal to get
- # channels = 10, width = 1700, height=350
- NUMBER_OF_DIM_TO_REDUCE = 10
- sample_matrix = np.random.randint(0, 100, size=(width, height, channels))
- # declare only once from scikit learn
- pca = None
- def get_reduced_dimensions(input_matrix):
- # do dimension reduction on
- # in theory you want to return of shape
- # height, NUMBER_OF_DIM_TO_REDUCE
- # but i am just returning random one now
- return np.random.randint(0, 100, size=(height, NUMBER_OF_DIM_TO_REDUCE))
- def get_channel_as_pca_input(matrix, column):
- return matrix[column,:,:]
- # we need to reduce from 200 channels to day 10, so we need to get all channels for a given channel
- all_channels_for_col_0 = get_channel_as_pca_input(sample_matrix, 0)
- # all_channels_for_col_0.shape = 350, 200
- # send all_channels_for_col_0 through get_reduced_dimensions function
- new_matrix_with_reduced_dimensions = np.random.randint(0, 100, size=(width, height, NUMBER_OF_DIM_TO_REDUCE))
- for i in range(width):
- all_channels = get_channel_as_pca_input(sample_matrix, i)
- reduced_dimension = get_reduced_dimensions(all_channels)
- new_matrix_with_reduced_dimensions[i,:,:] = reduced_dimension
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement