reconst2.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import numpy as np
  2. import tensorflow as tf
  3. PATCH_COUNT = 4000
  4. gabors = np.load('gabors.npy')
  5. #codes = np.load('codes/codesnnTruelamb4.0comps100codes800patches400000epochs16.npy')[:PATCH_COUNT]
  6. #basis = np.load('basis/basisnnTruelamb4.0comps100codes800patches400000epochs16.npy')
  7. #invPCA = np.load('inversePCA.npy')
  8. #v1cMean = np.load('v1cmean.npy')
  9. #angles = np.memmap('angles', dtype='float32', mode='r', shape = (4000000, 6, 6, 3, 12, 1))#np.load('angles.npy')
  10. #angles = angles[:PATCH_COUNT]
  11. v1 = np.memmap('v1Simple', dtype='float32', mode='r', shape = (4000000, 6, 6, 3, 12, 2))
  12. v1 = v1[:4000]
  13. v1 = np.array(v1, dtype = np.float64)
  14. #super = np.dot(codes, basis)
  15. #super = np.dot(super, invPCA)
  16. #super += v1cMean[:super.shape[0]]
  17. #super = super.reshape((super.shape[0], 6, 6, 3, 12, 1))
  18. #quadPair0 = super * np.cos(angles)
  19. #quadPair1 = super * np.sin(angles)
  20. #v1 = np.concatenate((quadPair0, quadPair1), axis = -1)
  21. v1Tensor = tf.convert_to_tensor(v1)
  22. v1Tensor = tf.reshape(v1Tensor, [PATCH_COUNT, 6, 6, -1])
  23. gaborsTensor = tf.convert_to_tensor(gabors)
  24. gaborsTensor = tf.reshape(gaborsTensor, [12, 12, 1, -1])
  25. reconst = tf.nn.conv2d_transpose(v1Tensor, gaborsTensor, [PATCH_COUNT, 32, 32, 1], [1, 4, 4, 1], padding = 'VALID')
  26. np.save('reconst2.npy', reconst.numpy())