Apr-07-2022, 07:40 PM
Hello everyone,
I have been detached from Python for quite a while now, can someone explain this code to me as if I am a 5 year old?
Can someone kindly help me out?
Kind regards,
PythonNPC.
I have been detached from Python for quite a while now, can someone explain this code to me as if I am a 5 year old?
print (output2.shape) #Prints: "(1, 13, 13, 128)" n_features = output2.shape[-1] #Selects the last element of the list, 128 in this case. size = output2.shape[1] #Select the second element of the list, 13 in this case. display_grid = np.zeros((size, size * n_features)) for i in range(n_features): #Run the loop 128 times x = output2[0, :, :, i] #? x -= x.mean() #Finds the mean on x and subtracts it from x x /= x.std () #? x *= 64 #Multiplies x by 64 x += 128 #Adds 128 to x x = np.clip(x, 0, 255).astype('uint8') #? display_grid[:, i * size : (i + 1) * size] = x #? scale = 20. / n_features #? 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' ) #?I understood few of the simple lines, but I am not well versed with numpy and display_grid which is a part of matplotlib I guess.
Can someone kindly help me out?
Kind regards,
PythonNPC.