12345678910111213141516171819202122232425262728293031323334353637 |
- import numpy as np
- import tensorflow as tf
- PATCH_COUNT = 4000
- gabors = np.load('gabors.npy')
- #codes = np.load('codes/codesnnTruelamb4.0comps100codes800patches400000epochs16.npy')[:PATCH_COUNT]
- #basis = np.load('basis/basisnnTruelamb4.0comps100codes800patches400000epochs16.npy')
- #invPCA = np.load('inversePCA.npy')
- #v1cMean = np.load('v1cmean.npy')
- #angles = np.memmap('angles', dtype='float32', mode='r', shape = (4000000, 6, 6, 3, 12, 1))#np.load('angles.npy')
- #angles = angles[:PATCH_COUNT]
- v1 = np.memmap('v1Simple', dtype='float32', mode='r', shape = (4000000, 6, 6, 3, 12, 2))
- v1 = v1[:4000]
- v1 = np.array(v1, dtype = np.float64)
- #super = np.dot(codes, basis)
- #super = np.dot(super, invPCA)
- #super += v1cMean[:super.shape[0]]
- #super = super.reshape((super.shape[0], 6, 6, 3, 12, 1))
- #quadPair0 = super * np.cos(angles)
- #quadPair1 = super * np.sin(angles)
- #v1 = np.concatenate((quadPair0, quadPair1), axis = -1)
- v1Tensor = tf.convert_to_tensor(v1)
- v1Tensor = tf.reshape(v1Tensor, [PATCH_COUNT, 6, 6, -1])
- gaborsTensor = tf.convert_to_tensor(gabors)
- gaborsTensor = tf.reshape(gaborsTensor, [12, 12, 1, -1])
- reconst = tf.nn.conv2d_transpose(v1Tensor, gaborsTensor, [PATCH_COUNT, 32, 32, 1], [1, 4, 4, 1], padding = 'VALID')
- np.save('reconst2.npy', reconst.numpy())
|