koraykv / unsup

Some unsupervised learning modules using Torch
86 stars 36 forks source link

Issue with zca_whiten function #43

Closed iacolippo closed 7 years ago

iacolippo commented 7 years ago

I'm having problem with zca_whiten function. Either the code is stuck in the execution of this function or it takes too long. I'm on Ubuntu 16.04, unsup version 0.1-0, torch scm-1. Both when I call it like this

TrainDataProvider.Data, mean, P, invP = unsup.zca_whiten(TrainDataProvider.Data)

and like this, using a PreProcData from another system before the code stopped working

TrainDataProvider.Data = unsup.zca_whiten(TrainDataProvider.Data, mean, P, invP)

TrainDataProvider is

local TrainDataProvider = DataProvider.Container{
  Name = 'TrainingData',
  CachePrefix = nil,
  CacheFiles = false,
  Source = {TrainData.data,TrainData.label},
  MaxNumItems = 1e6,
  CopyData = false,
  TensorType = 'torch.FloatTensor',
}

Example of TrainData:

local TestData
local TrainData

mnist = require 'mnist'
TrainData = mnist.traindataset() 
TestData = mnist.testdataset()
Classes = {1,2,3,4,5,6,7,8,9,0}
TestData.data = TestData.data:view(TestData.data:size(1),1,28,28)
TrainData.data = TrainData.data:view(TrainData.data:size(1),1,28,28)
TestData.label = TestData.label:byte()
TrainData.label = TrainData.label:byte()

TrainData.label:add(1)
TestData.label:add(1)
TrainData.data = TrainData.data:float()
TestData.data = TestData.data:float()
iacolippo commented 7 years ago

In the end it had nothing to do with your code. Torch wasn't finding LAPACK to do the inverse. Solved by:

git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make NO_AFFINITY=1 USE_OPENMP=1
sudo make install
CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH luarocks install torch

Closing.