(x, npx=64, nc=3)
| 138 | |
| 139 | |
| 140 | def transform_im(x, npx=64, nc=3): |
| 141 | if nc == 3: |
| 142 | x1 = (x + sharedX(1.0)) * sharedX(127.5) |
| 143 | else: |
| 144 | x1 = T.tile(x, [1, 1, 1, 3]) * sharedX(255.0) # [hack] to-be-tested |
| 145 | |
| 146 | mean_channel = np.load(os.path.join(pkg_dir, 'ilsvrc_2012_mean.npy')).mean(1).mean(1) |
| 147 | mean_im = mean_channel[np.newaxis, :, np.newaxis, np.newaxis] |
| 148 | mean_im = floatX(np.tile(mean_im, [1, 1, npx, npx])) |
| 149 | x2 = x1[:, [2, 1, 0], :, :] |
| 150 | y = x2 - mean_im |
| 151 | return y |