class_docstr: Alternating Least Square to solve Canonical Polyadic Decompositon.
  
      
docstr: Compute the approximate original tensor
  
  Args:
      A (list of numpy.ndarray): matrices where the number of columns for each matrix is the same.
      lmbda (numpy.ndarray): 1-dimensional np.ndarray
docstr_tok: ["Compute","the","approximate","original","tensor","Args",":","A","(","list","of","numpy.ndarray",")",":","matrices","where","the","number","of","columns","for","each","matrix","is","the","same",".","lmbda","(","numpy.ndarray",")",":","1-dimensional","np.ndarray"]
code: def approximate_tensor(self, A, lmbda):
      """Compute the approximate original tensor
  
      Args:
          A (list of numpy.ndarray): matrices where the number of columns for each matrix is the same.
          lmbda (numpy.ndarray): 1-dimensional np.ndarray
      """
      rank = len(lmbda)
      Z = np.zeros([a.shape[0] for a in A])
      for r in range(rank):
          a0 = A[0][:, r]
          for a in A[1:]:
              a0 = np.multiply.outer(a0, a[:, r])
          Z[...] += lmbda[r] * a0
  
      #         # Multi-thread (takes much memory)
      #         def outer_prod(A, lmbda, r):
      #             a0 = A[0][:, r]
      #             for a in A[1:]:
      #                 a0 = np.multiply.outer(a0, a[:, r])
      #             return lmbda[r] * a0
      #         future_list = []
      #         for r in range(rank):
      #             future = self.pool.apply_async(outer_prod, (A, lmbda, r))
      #             future_list.append(future)
      #         results = []
      #         for r in range(rank):
      #             results.append(future_list[r].get())
      #         Z = reduce(lambda X, Y: X + Y, results)
  
      return Z
  
file_path: nnabla/python/src/nnabla/utils/factorization/cpd.py
imports: from functools import reduce
  import numpy
  from scipy.linalg import pinv
label_desc: Use image node_id 6 for calling the ALS obj's underlying member method code with example usage: obj.approximate_tensor(A, lmbda) and returns: Z