-
Notifications
You must be signed in to change notification settings - Fork 0
/
DimReduction.py
39 lines (25 loc) · 986 Bytes
/
DimReduction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 31 00:16:42 2019
@author: dmy
"""
from ops import *
import os
class DimReduction(object):
def __init__(self,args):
self.covseqs_dir = args.covseqs_dir
self.m = args.m
self.output = args.output
print("# target dimension : ", self.m)
print("# file name of covariance sequences : ", self.covseqs_dir)
def Optimize(self):
covseqs = np.load(self.covseqs_dir + '.npy')
n,n,T,L = covseqs.shape
traj = np.zeros((self.m, self.m, T, L))
B = np.zeros((n,self.m))
for j in range(L):
B = ManoptOptimization(covseqs[:,:,:,j],self.m)
for i in range(T):
traj[:,:,i,j] = reduce(np.dot, [B.T, covseqs[:,:,i,j], B])
name = self.output
np.save(name, traj)