Apr-07-2022, 08:37 PM
(This post was last modified: Apr-08-2022, 12:50 PM by deanhystad.)
Did you write the comments? I should limit feedback to lines with #? ?
Is this sufficient (as an example):
array.astype(type) casts the contents of an array to the specified type. astype() creates a new array which is returned.
Used in combination this clips an array so all numbers are in the range 0..255 and converts their type to uint8 (8 bit unsigned integers.). The new results are assigned to x. The old x is no longer referenced, so it will be deleted.
The result is the new x is a standardized version of the old x. Each value in x is the standardized deviation of the old x value from the mean. The new x will have a mean of 0 and a standard deviation of 1.
My knowledge is pretty spotty on numpy indexing so I will leave this one alone:
Is this sufficient (as an example):
x = np.clip(x, 0, 255).astype('uint8')clip(value, min, max) clips x to range 0, 255, If x > 255 it becomes 255. if x < 0 it becomes 0. clip() creates a new array which is returned.
array.astype(type) casts the contents of an array to the specified type. astype() creates a new array which is returned.
Used in combination this clips an array so all numbers are in the range 0..255 and converts their type to uint8 (8 bit unsigned integers.). The new results are assigned to x. The old x is no longer referenced, so it will be deleted.
x /= x.std ()std(x) computes the standard deviation of x. x =/std(x) divides the x array by the standard deviation of x and assigns the result to x. The old x is no longer referenced, so it will be deleted.
The result is the new x is a standardized version of the old x. Each value in x is the standardized deviation of the old x value from the mean. The new x will have a mean of 0 and a standard deviation of 1.
My knowledge is pretty spotty on numpy indexing so I will leave this one alone:
display_grid[:, i * size : (i + 1) * size] = xAll of this stuff creates a plot using matplotlib and saves it to a file. Do you need a description of each of the lines? It might be more informative to just plot the image (uncomment imshow line or call show(plt.show()).
plt.figure( figsize=(scale * n_features, scale) ) #? plt.title ( "conv2d" ) #? plt.grid ( False ) #? #plt.imshow( display_grid, aspect='auto', cmap='viridis' ) #? plt.imsave( "test.jpeg", display_grid, cmap='viridis' ) #?