models_learners.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:smp_base 作者: x75 项目源码 文件源码
def generate(self, type="2d"):
        if type == "2d":
            M = np.random.rand(self.ndims, self.ndims)
            print (M)
            M = sLA.orth(M)
            print (M)
            S = np.dot(np.diag([0, .25]), np.random.randn(self.ndims, self.l))
            print ("S.shape", S.shape)
            print (S)
            A = np.dot(M, S)
            print ("A.shape", A.shape)
            # print A
            return(A, S, M)

        elif type == "close":
            S = 2 * (np.random.rand(self.ndims, self.l) - 0.5)
            A = S
            print (A.shape)
            # A(2:end,:) = A(2:end,:) + A(1:end-1, :)/2;
            A[1:-1,:] = A[1:-1,:] + A[0:-2, :]/2.
            return (A, S, np.zeros((1,1)))

        elif type == "noisysinewave":
            t = np.linspace(0, 2 * np.pi, self.l)
            sine = np.sin(t * 10)
            # sine = 1.2 * (np.random.rand(1, self.l) - 0.5)
            # nu = 0.1 * (np.random.rand(1, self.l) - 0.5)
            # sine = 2.3 * np.random.randn(1, self.l)
            nu = 0.7 * np.random.randn(1, self.l)
            c1 = (2.7 * sine) + (2 * nu)
            c2 = (1.1 * sine) + (1.2 * nu)
            A = np.vstack((c1, c2))
            print (A.shape)
            # A(2:end,:) = A(2:end,:) + A(1:end-1, :)/2;
            # A[1:-1,:] = A[1:-1,:] + A[0:-2, :]/2.
            return (A, np.zeros((2, self.l)), np.zeros((1,1)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号