Lang:Python2
Edit12345678910111213141516171819202122232425262728293031import copydef relu(x):if x>0:return xelse:return 0def pre_process(x):return (x/127.5 - 1)def get_chanel(array, height, width, size):assert len(array) == height * width * sizechanels = list()for i in range(size):c = [e for e in array[i::size]]chanels.append(c)return chanelsdef array2d(array, height, width):res = []for i in range(height):res.append(array[i*height:(i+1)*height])return res# print array2d([1,2,3,4,5,6,7,8,9], 3, 3)def zeropadding(array_2d, height, width):a_width = len(array_2d[0])a_height = len(array_2d)