python—我现在正在研究一种算法来恢复数据,这种情况不允许使用神经网络

xxe27gdn  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(219)

以下代码显示了我面临的问题:“”

  1. def fakeDataGenerator(chanNum=31):
  2. # This function generates the data I want to recover and it shows the characters of the data I am working on. It's continuous and differentiable.
  3. peaks = random.sample(range(chanNum), random.choice(range(3,10)))
  4. peaks.append(chanNum)
  5. peaks.sort()
  6. out = [random.choice(range(-5, 5))]
  7. delta = 1
  8. while len(out) < chanNum:
  9. if len(out) < peaks[0]:
  10. out.append(out[-1]+delta)
  11. elif len(out) == peaks[0]:
  12. delta *= -1
  13. peaks.pop(0)
  14. return out
  15. originalData = torch.tensor(fakeDataGenerator(31)).reshape(1, 31).float()
  16. encoder = torch.rand((31, 9)).float() #encoder here is something that messed the data up
  17. code = torch.matmul(originalData, encoder) #here we get the code which is messed up by the encoder
  18. decoder = torch.pinverse(encoder) #We can make use of the encoder matrix to decode the data.
  19. # For example, here I apply pinverse to recover the data, but...
  20. decoded = torch.matmul(code, decoder)
  21. print(decoded - originalData) #the result is no good.

我能否利用原始数据和编码器的特性更好地恢复原始数据?这个程序工作的环境不允许像神经网络这样的复杂模型。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题