火花矩阵之外的分布式BlockMatrix

编程入门 行业动态 更新时间:2024-10-27 00:29:58
本文介绍了火花矩阵之外的分布式BlockMatrix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何用Matrices(相同大小)制作分布式BlockMatrix?

How to make a distributed BlockMatrix out of Matrices (of the same size)?

例如,假设A,B为两个2 x 2 mllib.linalg.Matrices,如下所示

For example, let A, B be two 2 by 2 mllib.linalg.Matrices as follows

import org.apache.spark.mllib.linalg.{Matrix, Matrices} import org.apache.spark.mllib.linalg.distributed.BlockMatrix val A: Matrix = Matrices.dense(2, 2, Array(1.0, 2.0, 3.0, 4.0)) val B: Matrix = Matrices.dense(2, 2, Array(5.0, 6.0, 7.0, 8.0)) val C = new BlockMatrix(???)

如何首先从A,B制作RDD[((Int, Int), Matrix)],然后从A,B制作分布式BlockMatrix?

How can I first make an RDD[((Int, Int), Matrix)] from A, B and second a distributed BlockMatrix out of A, B?

我会先感谢您的任何评论或帮助.

I'd appreciate any comment or help in advance.

推荐答案

您可以通过首先创建RDD[((Int, Int), Matrix)]

val blocks: RDD[((Int, Int), Matrix)] = sc.parallelize(Seq(((0, 0), A), ((0, 1), B))

,然后将其转换为BlockMatrix.

val blockMatrix: BlockMatrix = new BlockMatrix(blocks, 2, 2)

这将为您提供BlockMatrix,其格式为[A | B].

This will give you a BlockMatrix, which has the form [A | B].

更多推荐

火花矩阵之外的分布式BlockMatrix

本文发布于:2023-11-30 05:15:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648847.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分布式   矩阵   火花   BlockMatrix

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!