scala数据结构和算法-08-堆排序

推荐系统itembase算法scala实现 #尊重版权,转载注明地址#博主最近在学习scala,scala是面向函数编程,这与面向对象编程的java有着很大的差别,学习的第一个demo当然是声名显赫的wordcount,代码如下: val conf = new SparkConf() conf.setMaster("local[1]").setAppName("word count") val sc = new Spar 阅读详情

发布一个k8s部署视频:https://edu.youkuaiyun.com/course/detail/26967

课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。

腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518

第二个视频发布  https://edu.youkuaiyun.com/course/detail/27109

腾讯课堂连接地址https://ke.qq.com/course/484107?tuin=ba64518

介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。

第三个视频发布:https://edu.youkuaiyun.com/course/detail/27574

详细介绍helm命令,学习helm chart语法,编写helm chart。深入分析各项目源码,学习编写helm插件
————————————————------------------------------------------------------------------------------------------------------------------

二叉堆满足二个特性:

1.父结点的键值总是大于或等于(小于或等于)任何一个子节点的键值。

2.每个结点的左子树和右子树都是一个二叉堆(都是最大堆或最小堆)。

当父结点的键值总是大于或等于任何一个子节点的键值时为最大堆。当父结点的键值总是小于或等于任何一个子节点的键值时为最小堆。下图展示一个最小堆:

由于其它几种堆(二项式堆,斐波纳契堆等)用的较少,一般将二叉堆就简称为堆。

堆的存储

一般都用数组来表示堆,i结点的父结点下标就为(i – 1) / 2。它的左右子结点下标分别为2 * i + 1和2 * i + 2。如第0个结点左右子结点下标分别为1和2。

 

package data

import scala.collection.mutable.ListBuffer

object HeapSort {
  def buildHeap[T](comparator:(T,T)=>Boolean)(source:ListBuffer[T],parent:Int){
    if(left(parent)>=source.length){
      return 
    }else{
      buildHeap(comparator)(source,left(parent));
    }
    if(right(parent)>=source.length){
      return
    }else{
      buildHeap(comparator)(source,right(parent));
    }
    if(comparator(source(left(parent)),source(parent))
        &&comparator(source(right(parent)),source(parent))){
      if(comparator(source(left(parent)),source(right(parent)))){
        val p=source(parent)
        source(parent)=source(left(parent))
        source(left(parent))=p
        buildHeap(comparator)(source,left(parent))
      }else{
        val p=source(parent)
        source(parent)=source(right(parent))
        source(right(parent))=p
        buildHeap(comparator)(source,right(parent))
      }
    }else if(comparator(source(left(parent)),source(parent))){
      val p=source(parent)
        source(parent)=source(left(parent))
        source(left(parent))=p
        buildHeap(comparator)(source,left(parent))
    }else if(comparator(source(right(parent)),source(parent))){
      val p=source(parent)
        source(parent)=source(right(parent))
        source(right(parent))=p
        buildHeap(comparator)(source,right(parent))
    }
    
    
  }
  
  def left(parent:Int)={
    parent*2+1
  }
  
  def right(parent:Int)={
    parent*2+2
  }
  
  def heapfye[T](comparator:(T,T)=>Boolean)(source:ListBuffer[T],parent:Int,rightIndex:Int){
    if(left(parent)>rightIndex){
      return 
    }
    /*if(right(parent)>rightIndex){
      return
    }*/
    if(left(parent)<=rightIndex&&right(parent)>rightIndex){
       if(comparator(source(left(parent)),source(parent))){
          val p=source(parent)
            source(parent)=source(left(parent))
            source(left(parent))=p
            heapfye(comparator)(source,left(parent),rightIndex)
        }
    }else{
        if(comparator(source(left(parent)),source(parent))
            &&comparator(source(right(parent)),source(parent))){
          if(comparator(source(left(parent)),source(right(parent)))){
            val p=source(parent)
            source(parent)=source(left(parent))
            source(left(parent))=p
            heapfye(comparator)(source,left(parent),rightIndex)
          }else{
            val p=source(parent)
            source(parent)=source(right(parent))
            source(right(parent))=p
            heapfye(comparator)(source,right(parent),rightIndex)
          }
        }else if(comparator(source(left(parent)),source(parent))){
          val p=source(parent)
            source(parent)=source(left(parent))
            source(left(parent))=p
            heapfye(comparator)(source,left(parent),rightIndex)
        }else if(comparator(source(right(parent)),source(parent))){
          val p=source(parent)
            source(parent)=source(right(parent))
            source(right(parent))=p
            heapfye(comparator)(source,right(parent),rightIndex)
        }
    }
  }
  
  def heapSort[T](comparator:(T,T)=>Boolean)(source:ListBuffer[T],rightIndex:Int):ListBuffer[T]={
    for(i<-(1 until source.length).reverse){
      val tmp=source(i)
      source(i)=source(0)
      source(0)=tmp;
      heapfye(comparator)(source,0,i-1)
    }
    source
  }
  def main(args: Array[String]): Unit = {
    val source=ListBuffer(3,1,4,9,5,8,7)
    buildHeap[Int](_>_)(source,0)
    println(source.mkString(",")) 
    println(heapSort[Int](_>_)(source,source.length-1).mkString(","))
  }
}

 

 

 

 

 

Scala语言的数据结构 Scala的数据结构为开发者提供了多种选择,从基础的ListArraySet和Map到更高级的TreeSortedSet和并发集合,每种数据结构都具有其独特的用途和性能特性。通过合理选择和有效利用Scala的丰富数据结构,开发者可以构建出高效、可维护的应用程序。数据结构是编程的基石,掌握Scala中的各种数据结构不仅可以提升开发效率,还能增强解决问题的能力。在实际开发中,我们应根据具体的场景和需求,灵活选择合适的数据结构,以达到最佳的效果。 阅读详情

相关推荐

Scala思维导图--scala知识体系总结

Scala 是一门多范式(multi-paradigm)的编程语言,设计初衷是要集成面向对象编程和函数式编程的各种特性。 Scala 运行在Java虚拟机上,并兼容现有的Java程序。 Scala 源代码被编译成Java字节码,所以它可以运行于JVM之上,并可以调用现有的Java类库。 官网中详细的说明了scala的六大特性: 该思维导图总结了Scala基础及进阶的大部分知识,并提

weixin_35602748的博客 2088

大数据热门技术Spark+机器学习+贝叶斯算法第12季

本套大数据热门技术Spark+机器学习+贝叶斯算法系列课程,历经5年沉淀,调研企业上百家,通过上万学员汇总,保留较为完整的知识体系的同时,让每个模块看起来小而精,碎而不散。在本课程中基于大量案例实战,深度剖析和讲解Spark2.4原理和新特性,且会包含完全从企业真实业务需求中抽取出的案例实战。内容涵盖Spark核心编程、Spark SQL和Spark Streaming、Spark内核以及源码剖析、推荐系统、Kafka消费机制、Spark机器学习、朴素贝叶斯算法、企业级实战案例等。通过理论和实际的紧密结合,可以使学员对大数据Spark技术栈有充分的认识和理解,在项目实战中对Spark和流式处理应用的场景、以及大数据开发有更深刻的认识;并且通过对流处理原理的学习和与批处理架构的对比,可以对大数据处理架构有更全面的了解,为日后成长为架构师打下基础。本套教程可以让学员熟练掌握Spark技术栈,提升自己的职场竞争力,实现更好的升职或者跳槽,或者从J2EE等传统软件开发工程师转型为Spark大数据开发工程师,或是对于正在从事Hadoop大数据开发的朋友可以拓宽自己的技术能力栈,提升自己的价值。Spark应用场景Yahoo将Spark用在Audience Expansion中的应用,进行点击预测和即席查询等。淘宝技术团队使用了Spark来解决多次迭代的机器学习算法、高计算复杂度的算法等。应用于内容推荐、社区发现等。腾讯大数据精准推荐借助Spark快速迭代的优势,实现了在“数据实时采集、算法实时训练、系统实时预测”的全流程实时并行高维算法,最终成功应用于广点通pCTR投放系统上。优酷土豆将Spark应用于视频推荐(图计算)、广告业务,主要实现机器学习、图计算等迭代计算。本套大数据热门技术Spark+机器学习+贝叶斯算法共计13季,本套为第12季。

Scala数据结构

Scala的数据结构 数据结构——容器 容器(Collection) Scala中容器包 Scala的容器(collection)库 在Iterable(可迭代的)下的继承层次包括三个特质: 三种容器最大的区别是其元素的索引方式 序列(Seq):按照从0开始的整数进行索引 映射(Map) :按照键值进行索引 集合(Set):没有索引,使用哈希方式进行值的查找 Seq(序列) 序列(Sequence): 元素可以按照特定的顺序访问的容器。序列中每个元素均带有一个从0开始计数的固定索引位置 序列分类: LinearSeq(线性)序列具有高效的 head 和 tail 操作 IndexedSe

Scala的数据结构

Scala提供了许多数据结构,例如常见的数组、元组、和集合等。 1.数组 数组(Array)主要用来存储数据类型相同的元素 数组的定义与使用 Scala中的数组分为定长数组和变长数组,这两种数组的定义方式如下: 1 new Array[T](数组长度) //定义定长数组 2 ArrayBuffer[T]() //定义变长数组 ...

qq_58188786的博客 1610

避开这5个坑!ADNI数据库下载实操经验分享(含断点续传方案)

本文分享了ADNI数据库下载的5个常见陷阱及解决方案,包括高级搜索策略优化、断点续传技巧和数据完整性验证。特别针对大文件下载中断问题,提供了wget断点续传和分卷下载的实操方法,帮助研究者高效获取神经影像数据,避免重复下载和时间浪费。

git9versioner的博客 374

GD32F303定时器配置:实现两路互补PWM输出与相位控制

本文详细解析了基于GD32F303定时器实现两路互补PWM输出与精确相位控制的方法。通过配置TIMER2的中间对齐模式,结合REMAP功能解决引脚复用问题,从硬件层面稳定生成相位差180度的互补PWM信号,适用于电机驱动、开关电源等对时序要求苛刻的应用场景。

weixin_29182481的博客 308

50个必知必会算法实战指南:多语言实现深度解析

Algo项目是一个专注于数据结构和算法实践的开源库,提供了50个核心算法的多语言实现方案。这个项目由前Google工程师创建,旨在帮助开发者通过实际代码掌握算法精髓,提升编程面试和工程实践能力。项目覆盖从基础数据结构到高级算法的完整知识体系,支持C/C++、Java、Python、Go、JavaScript、TypeScript、Rust、Scala、Swift、Kotlin、PHP、Object

gitblog_00311的博客 498

fMRI数据处理:从DICOM到NIFTI(下)

上一篇我们完成了对原始DICOM的数据整理,将其整理为了BIDS目录结构。作为从从DICOM到NIFTI的最后一篇,当然是介绍如何批量将DICOM格式转NIFTI格式啦!从DICOM到NIFTI系列就完成啦!撒花★,°.°★。从核磁机器把数据拷回来——到整理成BIDS格式——到批量转格式;我们fMRI数据处理的第一步就算是正式迈出去啦!接下来的内容,敬请期待吧~

weixin_44933894的博客 2080

scala数据结构

元组也是可以理解为一个容器,可以存放各种相同或不同类型的数据。说的简单点,就是将多个无关的数据封装为一个整体,称为元组, 最多的特点灵 活,对数据没有过多的约束。注意:元组中最大只能有22个元素队列的说明队列是一个有序列表,在底层可以用数组或是链表来实现。

CarveStone的博客 1952

AGV路径规划实战:如何用Python+ROS实现激光SLAM导航(附避障代码)

本文提供了一份基于Python和ROS实现AGV激光SLAM导航的实战指南。内容涵盖从Docker环境搭建、激光雷达数据处理、Gmapping建图,到Move_Base全局/局部路径规划与TEB局部规划器配置的全流程。重点解析了如何通过参数调优实现稳定导航,并附带了紧急避障代码,帮助开发者快速构建具备自主路径规划与实时避障能力的AGV系统。

pepsi的博客 1238

Monocle2拟时轨迹基因模块的GO富集解析

本文详细解析了如何对Monocle2拟时分析中得到的基因表达模块进行GO富集分析。通过从热图对象中提取聚类模块,并利用clusterProfiler等工具进行功能注释,将抽象的基因表达时序模式转化为可解释的生物学功能主题,如免疫应答、细胞外基质组织等,从而深入理解细胞命运转变的驱动机制。

gpt4scribbler的博客 501

scala 系列之 05scala 数据结构

6 数据结构 ​ 在scala 编程中经常需要用到各种数据结构,比如数组(Array)、元组(Tuple)、列表(List)、映射(Map)、集合(Set)等。 ​ Scala同时支持可变集合和不可变集合,不可变集合从不可变,可以安全的并发访问; ​ 不可变集合:scala.collection.immutable ​ 可变集合: scala.collection.mutable ​ Scala优先采用不可变集合,对于几乎所有的集合类,Scala都同时提供了可变和不可变的版本;

heqingcool的博客 636

VL53L0X加盖玻片后精度暴跌?手把手教你完成串扰校准(CrossTalk Calibration)

本文详细解析了VL53L0X激光测距传感器加盖玻片后精度下降的原因,并提供了串扰校准(CrossTalk Calibration)的完整解决方案。通过分步指导和实用代码示例,帮助工程师恢复毫米级测距精度,适用于智能门锁、扫地机器人等应用场景。

weixin_33708432的博客 540

(理论)推荐系统——从0开始大数据开发实战:电影推荐系统(scala版)

一、推荐系统 根据用户的历史数据发掘用户的潜在需求。 二、长尾商品 区别于热门商品,热门商品代表用户们的普遍需求,而长尾商品代表用户的个性化需求。 三、推荐方法 1)专家推荐(人工推荐):资深专家根据经验给出推荐。 2)统计推荐(热门推荐):根据历史记录进行统计,得出推荐结果,简单有效。 3)内容推荐:利用机器学习,根据物品的特性,找出相似物品。 4)协同过滤推荐:根据本用户的历史数据,找出最相近的用户,根据最近用户对某物品的喜好,计算本用户对该物品的喜好程度。 5)混合推荐:..

qq_40959369的博客 3869

PX4飞控CAN总线通信深度配置:从menuconfig到驱动加载的完整指南

本文详细解析了PX4飞控中CAN总线通信的深度配置流程,从menuconfig选项设置到驱动加载的完整指南。涵盖硬件抽象层、驱动层和应用层的配置细节,提供实际验证方法和故障排查技巧,帮助开发者高效实现CAN通信,特别适用于无人机和机器人底盘运动控制等场景。

weixin_30374009的博客 502

YOLOv8目标出入计数部署:讲解C#使用ONNX检测模型进行目标出入计数 可运行完整实例

代码、步骤、讲解完整,可一键运行,效果如下:车辆出入计数人员出入计数。

Limiiiing的博客 86

scala最大堆最小堆,取TopN

用scala实现一个最大堆或最小堆 并且维护一个长度为N的最小堆取,用来取TopN 定义一个HeapSort class /** * 堆排序:采用大顶堆,根节点大于两层元素,该类需要满足具备三个方法: 1.由正常数组变换为符合堆结构的方法 * 2.向堆中插入数据。3.从堆中删除数据。 * 重要特性:1.根节点索引值为i,根节点元素满足Key[i]>=Key[2i+1]&&...

woods的博客 1248

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

基于Scala开发Spark ML的ALS推荐模型实战

ALS算法是Spark ML中实现协同过滤的矩阵分解方法。ALS,即交替最小二乘法(Alternating Least Squares),是协同过滤技术中的一种经典算法。它通过对用户和物品的潜在特征进行建模,来预测用户对未知物品的评分或偏好。矩阵分解模型:在推荐系统中,我们通常有一个用户-物品的评分矩阵,其中行表示用户,列表示物品,矩阵中的值代表用户对物品的评分。然而,这个矩阵通常是非常稀疏的,因为用户只给少数物品评分。ALS算法就是在这样的不完整评分矩阵上操作,通过矩阵分解来补全缺失值,进而产生推荐。

pblh123的专栏 1699

深度学习工具包 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")

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Scala数据结构简单介绍

对Scala数据结构的简单了解,并且对比它们的不同。

weixin_74304418的博客 898

计算机控制技术及应用

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

Study 1.6 掌握Scala数据结构

ArrayBuffer的API文档:https://www.scala-lang.org/api/current/scala/collection/mutable/ArrayBuffer.html。ListBuffer的API文档:https://www.scala-lang.org/api/current/scala/collection/mutable/ListBuffer.html。注意:在创建集合时,4.5是第二个元素,但是创建完之后的集合里,4.5成为了最后一个元素,这正好说明了集合的无序性。

weixin_64270471的博客 239
上一篇: scala数据结构和算法-07-希尔排序
下一篇: scala数据结构和算法-09-基于插入排序的基数排序
hxpjava1
博客等级 码龄19年 1365粉丝 511原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hxpjava1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值