Spark Programming Guide(二)

Spark编程指南(Spark Programming Guide) 作者:禅与计算机程序设计艺术 1.简介 Spark是一个开源的快速、通用、可扩展的大数据处理系统,它提供了Java、Scala、Python、R等多语言API,可以运行在Hadoop、Apache Spark、Kubernetes、Mesos等分布式计算集群上,提供高吞吐量、低延迟的数据分析处理能力。S 阅读详情
Basics

To illustrate RDD basics, consider the simple program below:
仔细观察下面的程序,介绍了RDD的基本功能:

val lines = sc.textFile("data.txt")
val lineLengths = lines.map(s => s.length)
val totalLength = lineLengths.reduce((a, b) => a + b)

The first line defines a base RDD from an external file. This dataset is not loaded in memory or otherwise acted on: lines is merely a pointer to the file. The second line defines lineLengths as the result of a map transformation. Again, lineLengths is not immediately computed, due to laziness. Finally, we run reduce, which is an action. At this point Spark breaks the computation into tasks to run on separate machines, and each machine runs both its part of the map and a local reduction, returning only its answer to the driver program.

第一行代码从外部文件定义了一个基本的RDD,这里数据集并没有被真正的加载进内存,这里仅仅是建立了一个指向文件的一个指针。第二行定义了一个lineLengths的数据集由第一个数据集转换操作产生。同样由于RDD是惰性加载的,这里lineLengths并不会立即进行计算。最后,我们执行了action进行reduce计算。到此时Spark将计算任务分配到不同的机器上,每台机器同时对分区数据进行map和本地的reduce操作,最后把结果数据返回到驱动程序。

If we also wanted to use lineLengths again later, we could add:

如果我们在后面需要继续使用lineLengths,我们可以调用如下方法:

lineLengths.persist()

before the reduce, which would cause lineLengths to be saved in memory after the first time it is computed.

当执行第一个reduce计算操作之后lineLengths将会被持久化到内存中

Passing Functions to Spark

Spark’s API relies heavily on passing functions in the driver program to run on the cluster. There are two recommended ways to do this:

Spark的API很大程度上依赖于从驱动程序传递函数到集群之上,这里有两种推荐的方法来做这件事:

  1. Anonymous function syntax, which can be used for short pieces of code.

使用简短的匿名函数语法

  1. Static methods in a global singleton object. For example, you can define object MyFunctions and then pass MyFunctions.func1, as follows:

使用全集单例对象的静态方法。比如,你可以定义一个对象MyFunctions并且调用MyFunctions.func1方法,就像下面:

object MyFunctions {
  def func1(s: String): String = { ... }
}

myRdd.map(MyFunctions.func1)

Note that while it is also possible to pass a reference to a method in a class instance (as opposed to a singleton object), this requires sending the object that contains that class along with the method. For example, consider:

注意,虽然还可以传递类实例中的方法的引用(而不是单例对象),但这需要将包含该类的对象连同方法一起发送出去。例如,考虑:

class MyClass {
  def func1(s: String): String = { ... }
  def doStuff(rdd: RDD[String]): RDD[String] = { rdd.map(func1) }
}

Here, if we create a new MyClass instance and call doStuff on it, the map inside there references the func1 method of that MyClass instance, so the whole object needs to be sent to the cluster. It is similar to writing rdd.map(x => this.func1(x)).

这里,如果我们创建一个MyClass的实例并调用了它的doStuff方法,这里的map操作中引用了MyClass实例的func1方法,所以整个MyClass对象都需要被发送的集群上,等同于rdd.map(x => this.func1(x)).

In a similar way, accessing fields of the outer object will reference the whole object:

以类似的方式,访问外部对象的字段将引用整个对象:

class MyClass {
  val field = "Hello"
  def doStuff(rdd: RDD[String]): RDD[String] = { rdd.map(x => field + x) }
}

is equivalent to writing rdd.map(x => this.field + x), which references all of this. To avoid this issue, the simplest way is to copy field into a local variable instead of accessing it externally:

这等同于rdd.map(x => this.field + x),引用了整个对象。最简单的方法是将字段复制到本地变量,而不是外部访问它:

def doStuff(rdd: RDD[String]): RDD[String] = {
  val field_ = this.field
  rdd.map(x => field_ + x)
}
Understanding closures

One of the harder things about Spark is understanding the scope and life cycle of variables and methods when executing code across a cluster. RDD operations that modify variables outside of their scope can be a frequent source of confusion. In the example below we’ll look at code that uses foreach() to increment a counter, but similar issues can occur for other operations as well.

想要理解Spark的方法和变量在集群中的生命周期是比较困难的。RDD操作在其范围之外修改变量可能是造成混淆的常见原因。在下面的示例中,我们将查看使用foreach()来增加计数器的代码,但是类似的问题也可能发生在其他操作中。

Example

Consider the naive RDD element sum below, which may behave differently depending on whether execution is happening within the same JVM. A common example of this is when running Spark in local mode (–master = local[n]) versus deploying a Spark application to a cluster (e.g. via spark-submit to YARN):

看下面一个简单的 RDD 元素求和,执行结果可能不同,具体取决于是否在同一个 JVM 中执行. 一个常见的例子是当 Spark 运行在 local 本地模式(–master = local[n])时,与部署 Spark 应用到群集(例如,通过 spark-submit 到 YARN):

var counter = 0
var rdd = sc.parallelize(data)

// Wrong: Don't do this!!
rdd.foreach(x => counter += x)

println("Counter value: " + counter)
Local vs. cluster modes

The behavior of the above code is undefined, and may not work as intended. To execute jobs, Spark breaks up the processing of RDD operations into tasks, each of which is executed by an executor. Prior to execution, Spark computes the task’s closure. The closure is those variables and methods which must be visible for the executor to perform its computations on the RDD (in this case foreach()). This closure is serialized and sent to each executor.

上述代码的行为未定义,可能不会按预期的方式工作。执行作业时,Spark将会分解RDD操作并加入到任务队列中,每个任务都运行在一个单独的执行器中。在执行之前,Spark将确认任务的闭包,而闭包是在RDD上的executor必须能够访问的变量和方法(例中的 foreach())。闭包被序列化并被发送到每个执行器。

The variables within the closure sent to each executor are now copies and thus, when counter is referenced within the foreach function, it’s no longer the counter on the driver node. There is still a counter in the memory of the driver node but this is no longer visible to the executors! The executors only see the copy from the serialized closure. Thus, the final value of counter will still be zero since all operations on counter were referencing the value within the serialized closure.

闭包的变量副本发给每个 counter ,当 counter 被 foreach 函数引用的时候,它已经不再是 driver node 的 counter 了。虽然在 driver node 仍然有一个 counter 在内存中,但是对 executors 已经不可见。executor 看到的只是序列化的闭包一个副本。所以 counter 最终的值还是 0,因为对 counter 所有的操作均引用序列化的 closure 内的值。

In local mode, in some circumstances the foreach function will actually execute within the same JVM as the driver and will reference the same original counter, and may actually update it.

在 local 本地模式,在某些情况下的foreach功能实际上是同一JVM上的驱动程序中执行,并会引用同一个原始的counter计数器,实际上可能进行更新操作.

To ensure well-defined behavior in these sorts of scenarios one should use an Accumulator. Accumulators in Spark are used specifically to provide a mechanism for safely updating a variable when execution is split up across worker nodes in a cluster. The Accumulators section of this guide discusses these in more detail.

为了确保类似的场景下行为明确应用使用累加器(Accumulator)。Spark的累加器使用了一种特殊的方式提供了一种安全的机制去更新集群中各个worker节点的变量。本指南的累加器部分将更详细地讨论这些问题。

In general, closures - constructs like loops or locally defined methods, should not be used to mutate some global state. Spark does not define or guarantee the behavior of mutations to objects referenced from outside of closures. Some code that does this may work in local mode, but that’s just by accident and such code will not behave as expected in distributed mode. Use an Accumulator instead if some global aggregation is needed.

通常情况下,closures - constructs类似于循环或局部定义的方法,不应该用户去改变一些全局的状态。Spark不能保证类似的行为能够正常的执行。有些代码可以在本地模式下工作,但这只是偶然的,这样的代码在分布式模式下不会像预期的那样运行。如果需要一些全局的聚合功能,应使用 Accumulator(累加器)。

Printing elements of an RDD

Another common idiom is attempting to print out the elements of an RDD using rdd.foreach(println) or rdd.map(println). On a single machine, this will generate the expected output and print all the RDD’s elements. However, in cluster mode, the output to stdout being called by the executors is now writing to the executor’s stdout instead, not the one on the driver, so stdout on the driver won’t show these! To print all elements on the driver, one can use the collect() method to first bring the RDD to the driver node thus: rdd.collect().foreach(println). This can cause the driver to run out of memory, though, because collect() fetches the entire RDD to a single machine; if you only need to print a few elements of the RDD, a safer approach is to use the take(): rdd.take(100).foreach(println).

另一种常见的语法用于打印 RDD 的所有元素使用rdd.foreach(println)或rdd.map(println)。在单台机器上,这将预期输出和打印 RDD 的所有元素。在集群模式下,标准输出将会被集群节点中的executor所替代,而不会再驱动程序中输出,所以驱动程序中不会输出元素信息!要打印 driver 程序的所有元素,可以使用的 collect() 方法首先把 RDD 放到 driver 程序节点上,像这样: rdd.collect().foreach(println)。但是这可能会导致驱动节点内存耗尽,由于collect()会获取RDD所有元素到一台机器上,如果你仅仅需要打印几个元素,一种更安全的方式是使用take()方法:rdd.take(100).foreach(println).

《拉依达的嵌入式\驱动面试宝典》—C/CPP基础篇(二) 《拉依达的嵌入式\驱动面试宝典》 整合了所有我认为可能遇到的技术面试问题。所有问题及其答案均是我个人学习后查阅资料总结,每个回答都做了仔细的分析,在嵌入式及其驱动面试相关问题解析做到全网独一无二。学习或者转行到嵌入式、驱动开发领域学习的不二之选 阅读详情

相关推荐

LLM大模型-vLLM本地部署全流程:Windows WSL2环境安装、HuggingFace与Modelscope模型加载与本地运行、Docker化部署与镜像分发

vLLM本地部署大模型方案 vLLM是一款高性能大模型推理引擎,通过PagedAttention技术显著提升吞吐量和内存效率,支持低成本、高并发的本地部署。 核心优势: 性能卓越:吞吐量远超同类方案,支持连续批处理等高级功能 成本优化:减少GPU服务器需求 兼容性强:提供类OpenAI的简洁API 部署步骤: 硬件准备:需NVIDIA GPU(如A100/3090),显存≥模型参数量×2(7B模型需14GB) 软件环境: Linux系统或Windows WSL2 安装CUDA 12.1+和Python 3.

2202_75674969的博客 4565

Spark-RDD Programming Guide官网二

Overview Spark中的第二个抽象是可用于并行操作的共享变量。默认情况下,当Spark作为不同节点上的一组任务并行运行函数时,它将函数中使用的每个变量的副本发送给每个任务。有时候,需要在任务之间或任务和驱动程序之间共享变量。Spark支持两种类型的共享变量:广播变量(可以用于在所有节点的内存中缓存值)和累加器(仅“添加”到其中的变量,如计数器和和)。 Linking with Spark ...

weixin_36051743的博客 261

ADS 2023 实战:手把手教你仿真一个中心频率 2.4GHz 的带通滤波器(附工程文件)

本文详细介绍了使用ADS 2023软件设计和仿真中心频率2.4GHz带通滤波器的全流程,包括工程准备、指标定义、原理图设计、仿真优化及实际电路实现。通过切比雪夫滤波器拓扑和参数优化,实现高性能的带通滤波器设计,适用于无线通信系统。附有工程文件和常见问题解决方案,助力工程师快速掌握射频滤波器设计技巧。

weixin_30790841的博客 481

spark streaming programming guide 快速开始(二)

原文网站: http://spark.apache.org/docs/latest/streaming-programming-guide.html 本篇译文链接: http://spark.apache.org/docs/latest/streaming-programming-guide.html#a-quick-example 在深入了解spark str

newchitu的博客 370

IP白名单校验

支持格式: 1、127.0.0.1 // 指定固定IP 2、127.0.0.1-127.0.0.128 // 可使用“-”来表示一个IP区间,支持跨IP段(一般不会出现这种情况,跨IP段则配置多个规则) 3、127.0.* // 2~4位IP段可...

2199

手把手教你学 MATLAB 实战训练(6.9):卷积神经网络(CNN)模型来进行图像分类任务(预训练的 ResNet-50 模型)

加载数据集数据预处理加载预训练模型修改和扩展预训练模型设置训练选项训练模型测试模型。

xiaoheshang_123的博客 646

Spark Programming Guide (Python) Spark编程指南 (二)

原始版本参见:http://cholerae.com/2015/04/11/-%E7%BF%BB%E8%AF%91-Spark%E7%BC%96%E7%A8%8B%E6%8C%87%E5%8D%97-Python%E7%89%88/ 对部分内容有修改,恕本人水平有限,如有错误,在所难免。 PySpark编程指南(译):   1.  概述: a)  从高层次上来看,每一个Spa

ColdCode's Hello World~ 1862

Cleo Synchronization接口任意文件读取漏洞CVE-2024-50623 附POC

微信公众号搜索:南风漏洞复现文库该文章 南风漏洞复现文库 公众号首发Cleo。

nnn2188185的博客 480

RDD编程指引(二)(部分翻译Spark官网文章RDD Programming Guide)

本人刚开始入门学习Spark,打算先将Spark文档看一遍,顺便做点笔记,就进行一些翻译和记录。由于本人只会python,所以翻译都是以python部分代码进行。以下并非完全100%官网翻译,更多是个人理解+笔记+部分个人认为重要的内容的翻译,新手作品,请各位大神多多指正。 官网原文链接:http://spark.apache.org/docs/latest/rdd-programming-g...

alendx的博客 381

9、傅里叶变换:连续时间与离散时间信号分析的核心工具

本文深入探讨了傅里叶变换在连续时间和离散时间信号分析中的核心作用,详细介绍了连续时间傅里叶变换(CTFT)和离散时间傅里叶变换(DTFT)的定义、性质及其应用。文章涵盖了傅里叶级数到傅里叶变换的推导过程、常见变换对、系统分析中的关键性质,并讨论了采样后频谱的周期延拓与混叠问题。此外,还展示了傅里叶变换在滤波器设计、通信系统调制解调等实际场景中的应用,最后展望了其在图像处理、生物医学等领域的广阔前景。

jump7的博客 66

【BUG已解决】pip install 出现 error: Microsoft Visual C++ 14.0 or greater is required 解决方案

方案磁盘占用适用场景推荐指数安装Build Tools3-6GB长期Windows Python开发⭐⭐⭐⭐⭐寻找预编译wheel无额外占用只是想快速装上某个包⭐⭐⭐⭐⭐用conda安装视包而定已经在用conda环境⭐⭐⭐⭐⭐升级到新版本无额外占用库本身有更新的预编译版本⭐⭐⭐⭐使用WSL2需要额外配置Linux子系统频繁遇到Windows编译问题⭐⭐⭐⭐的核心是Windows 缺少本地 C/C++ 编译器,而目标包需要在本机编译。先看是否有捷径。

博客 1万+

【Spark】【翻译】RDD Programming Guide

Spark官方文档翻译系列,RDD编程指南(RDD Programming Guide)

petrel2015的博客 1354

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Spark Programming Guide

目录一、Spark Programming Guide1.Overview2.Linking with Spark连接3.Initializing SparkUsing the Shell4.Resilient Distributed Datasets (RDDs)弹性分布式数据集Parallelized CollectionsExternal Datasets(外部数据集)RDD Operati...

leaeason的博客 341

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Spark1.1.0 Spark SQL Programming Guide

Spark SQL Programming Guide OverviewGetting StartedData Sources RDDs Inferring the Schema Using ReflectionProgrammatically Specifying the Schema Parquet Files Loading Data Programmaticall

luyee2010的专栏 7249

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Spark Streaming Programming Guide

简述 Spark Streaming 是核心 Spark API 的扩展,支持可伸缩、高吞吐量、容错的实时数据流处理。数据可以从许多来源获取,如Kafka、Flume、Kinesis 或 TCP sockets,可以使用复杂的算法处理数据,这些算法用高级函数表示,如 map、reduce、join和window。最后,处理后的数据可以推送到文件系统、数据库和活动仪表板。实际上,您可以将 Spar...

主要写大数据集群一线运维和学习工作经验 416

Spark1.1.0 Spark Programming Guide

Spark Programming Guide OverviewLinking with SparkInitializing Spark Using the Shell Resilient Distributed Datasets (RDDs) Parallelized CollectionsExternal DatasetsRDD Operations BasicsPa

luyee2010的专栏 5326

Spark GraphX Programming Guide 编程指南

6、 Spark GraphX Programming Guide 6.1 概述 GraphX是spark的一个新组件用于图和并行图计算。在一个高水平,GraphX通过引进一个新的图抽象扩展了spark RDD:带有顶点和边属性的有向多重图。为了支持图计算,GraphX 提供了很多基本的操作(像 subgraph, joinVertices, and aggregateMessages

Spark MLlib 机器学习 3492

Spark1.1.0 Spark Streaming Programming Guide

Spark Streaming Programming Guide OverviewA Quick ExampleBasic Concepts LinkingInitializing StreamingContextDiscretized Streams (DStreams)Input DStreamsTransformations on DStreamsOutput Operatio

luyee2010的专栏 7511

Spark-RDD Programming Guide

RDD Programming Guide Overview Linking with Spark Initializing Spark Using the Shell Resilient Distributed Datasets (RDDs) Parallelized Collections External Datasets RDD Operations Basics Passing Functions to Spark Understanding closure

cxu123321的博客 359

Spark Streaming Programming Guide(翻译)

近期做目需要用到Spark的流处理框架,故进行了官方文档的阅读,顺手翻译在此。概要Spark流是对于Spark核心API的拓展,从而支持对于实时数据流的可拓展,高吞吐量和容错性流处理。数据可以由多个源取得,例如:Kafka,Flume,Twitter,ZeroMQ,Kinesis或者TCP接口,同时可以使用由如map,reduce,join和window这样的高层接口描述的复杂算法进行处理。最终,处

u013491151的专栏 2030

spark programming guide

一: 概要 从高级来看,每一个spark应用都包含一个驱动程序,执行用户的main方法,在cluster上执行不同的并行计算。spark提供的主要抽象是RDD,这是一个可以在cluster的各个节点上并行计算的分区元素的集合。创造RDD的方法是:使用一个hadoop文件系统中的文件,或者其他的hadoop支持的文件系统,或者是驱动中存在的scala的集合,然后也可以通过tranforma

yuangeqing的博客 490

spark python编程指南_Spark 编程指南 (一) [Spark Programming Guide]

Python Programming Guide - Spark(Python)Spark应用基本概念每一个运行在cluster上的spark应用程序,是由一个运行main函数的driver program和运行多种并行操作的executes组成其中spark的核心是弹性分布式数据集(Resilient Distributed Dataset—RDD)Resilient(弹性):易变化、易计算Di...

weixin_39924329的博客 153

Spark官方文档翻译:Spark Programming Guide(一)

spark中文文档

源码有毒的专栏 1195
上一篇: Spark官方文档翻译:Spark Programming Guide(一)
下一篇: Spark Programming Guide(三)
coley-wu
博客等级 码龄12年 859粉丝 112原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值