GithubHelp home page GithubHelp logo

tf-decompose's Introduction

tf-decompose

CP and Tucker tensor decompositions implemented in TensorFlow.

Usage

import numpy as np
import tensorflow as tf
from scipy.io.matlab import loadmat
from ktensor import KruskalTensor

# Load sensory bread data (http://www.models.life.ku.dk/datasets)
mat = loadmat('data/bread/brod.mat')
X = mat['X'].reshape([10,11,8])

# Build ktensor and learn CP decomposition using ALS with specified optimizer
T = KruskalTensor(X.shape, rank=3, regularize=1e-6, init='nvecs', X_data=X)
X_predict = T.train_als(X, tf.train.AdadeltaOptimizer(0.05), epochs=20000)

# Save reconstructed tensor to file
np.save('X_predict.npy', X_predict)

Kruskal tensors

Notes on ALS gradient computation

  • For CP decomposition we use alternating least squares' (ALS) over component matrices, but do not compute the exact solution as in Kolda & Bader (2009) due to the computational demands of computing large matrix inversions.
  • In our tests we find inferior results to the exact solution descent method (requires inverting potentially huge matrices) implemented in scikit-tensor with ~.80 vs. ~.90 fit with decomposed rank-3 tensors on the Sensory Bread dataset.
  • tf-decompose parallelized on GPU was approximately 20 times faster than scikit-tensor for a rank-200 decomposition of a random tensor with 60 million parameters.

Tucker tensors

Preliminary results: with sensory bread data, TuckerTensor.hosvd seems to perform quite poorly, while TuckerTensor.hooi and DecomposedTensor.train_als learn reconstructions with fit ~0.70.

References

Bader, Brett W., and Tamara G. Kolda. "Efficient MATLAB computations with sparse and factored tensors." SIAM Journal on Scientific Computing 30.1 (2007): 205-231.

Kolda, Tamara G., and Brett W. Bader. "Tensor decompositions and applications." SIAM review 51.3 (2009): 455-500.

Nickel, Maximilian. scikit-tensor


Also see: tensorD (code, paper). I wrote tf-decompose before this was available; I haven't used it, but you should check it out as well if you're considering using tf-decompose.

tf-decompose's People

Contributors

adamlauretig avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.