I am trying to convert Python Numpy code to Julia. Its has 5 dataset with each 10000 rows and 3072 columns.
Data is 10000x3072 numpy array of uint8s. Each row of the array stores a 32x32 colour image. The first 1024 entries contain the red channel values, the next 1024 the green, and the final 1024 the blue. The image is stored in row-major order, so that the first 32 entries of the array are the red channel values of the first row of the image.
Python Numpy Code
#1st function which sends 1 file name at a time to 2nd function to load data xs=; for b in range(1,6): xs.append(X);#above array is appened 5 times. Xtr=np.concatenate(xs); retrurn Xtr #2nd function load file from disk X=X.reshape(10000, 3, 32, 32).transpose(0,2,3,1).astype("float"); return X #Finally once the Xtr is returned, Xtr_rows becomes 50000 x 3072 Xtr_rows = Xtr.reshape(Xtr.shape, 32 * 32 * 3)
#1st function which sends 1 file name at a time to 2nd function to load data xs= for b=1:5 push!(xs,X) push!(ys,Y) end Xtr = convert.(Float64,vcat(xs...)) return Xtr #2nd function load file from disk X=permutedims(reshape(X,10000,3,32,32), [1,3,4,2]) retrun X #Finally once the Xtr is returned, Xtr_rows becomes 50000 x 3072 Xtr_rows= reshape(Xtr,size(Xtr,1), 32*32*3);
The results which i get are different. 1st and last columns of the array
Xtr_rows are same but rest of the columns are different. I am sure this is because Python is row major and Julia is column major hence it affect while reshaping the array. I believe i have tried different combination while reshaping but i am not getting the desired result.
Kindly let me know how to solve this issue.