Dubbo服务 初学配置

Dubbo 注册,调用,通信,容错 3种开发方式开发方式举例特点XML配置等业务代码零侵入扩展修改方便注解方式扩展修改方便修改需要重新编译代码API编程ReferenceConfig应用业务侵入性大修改复杂修改后需要重新编译。 阅读详情

一、先下载安装zookeeper

1.解压后 conf:zoo_sample .cfg 复制一份 改为zoo.cfg即可。里面有配置,暂时用不到,也可以到网上搜,很多。


2.执行相应的指令,我的是win10 

图1


图2 运行成功图片


二、部署dubbo-admin的war包,我用的是Tomcat7安装板做容器(非解压使用版)

1.下载 dubbo-admin-2.5.4-SNAPSHOT.war 网上版本很多

2.放在tomcat的webapps文件下,启动bin目录下的图形界面,解压war包,其实也可以用一些解压工具解压。

图1


启动Tomcate解压war



点击start即可 ,发现war被解压


解压后多的文件

先暂停tomcat,修改默认端口号8080为8090 ,因为8080zookeeper占用了,因为接下来要进入dubbo服务查询页面。

 

3.这里面有个配置文件dubbo.properties 有登陆的账号密码

http://localhost:8090/dubbo-admin-2.5.4-SNAPSHOT/  输入账户密码即可看到 下面界面 




三、具体的编码

1>.provider 提供服务者

大致结构;


创建maven项目(不会的可以搜一下)我使用idea

1.创一个接口:

package com.huilong.service;

import com.huilong.model.User;

/**
 * Created by 18358 on 2016/8/10.
 */
public interface UserService {

    User find(Long id);
}

2.实现接口:

package com.huilong.impl;

import com.huilong.model.User;
import com.huilong.service.UserService;

/**
 * Created by 18358 on 2016/8/10.
 */
public class UserServiceImpl implements UserService {
    public User find(Long id) {

        User user = new User();
        user.setAge(27);
        user.setId(1);
        user.setName("zhanghl");
        return user;
    }
}
3.核心配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
    <!-- 具体的实现bean -->
    <bean id="userService" class="com.huilong.impl.UserServiceImpl" />
    <!-- 提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="provider"  />
    <!-- 使用zookeeper注册中心暴露服务地址 -->
    <dubbo:registry address="zookeeper://127.0.0.1:2181" />
    <!-- 用dubbo协议在20880端口暴露服务 -->
    <dubbo:protocol name="dubbo" port="29014" />
    <!-- 声明需要暴露的服务接口 -->
    <dubbo:service interface="com.huilong.service.UserService" ref="userService" />
</beans>

4.测试类用于到注册中心 注册提供服务

package com.huilong.service;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * Created by 18358 on 2016/8/10.
 */
public class TestUser {
    public static void main(String[] args){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"application.xml"});
        context.start();
        System.out.print("服务注册成功");
        try {
            System.in.read();//让服务一致提供
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
5.pom.xml  依赖关系

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
  <groupId>com.huilong</groupId>
  <artifactId>provider</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>  
      <spring.version>3.2.8.RELEASE</spring.version>
      <!-- junit -->
      <junit.version>4.11</junit.version>
  </properties>  

  <dependencies>  
      <dependency>  
          <groupId>com.alibaba</groupId>  
          <artifactId>dubbo</artifactId>  
          <version>2.5.3</version>  
          <exclusions>  
              <exclusion>  
                  <groupId>org.springframework</groupId>  
                  <artifactId>spring</artifactId>  
              </exclusion>  
          </exclusions>  
      </dependency>  
      <dependency>  
          <groupId>com.github.sgroschupf</groupId>  
          <artifactId>zkclient</artifactId>  
          <version>0.1</version>  
      </dependency>
      <!-- spring相关 -->
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-beans</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-aop</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context-support</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jms</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <!-- junit4 -->
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>${junit.version}</version>
      </dependency>
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
          <scope>test</scope>
      </dependency>
  </dependencies>  
</project>

然后运行注册服务的main方法


之后可以去dubbo服务页面查询 当前接口服务是否已经真正注册成功



2> 服务消费者 

大致结构:


1.创建下一个新的maven项目

2.pom.xml 比上一个项目仅仅多出来 一个依赖即可

<dependency>
  <groupId>com.huilong</groupId>
  <artifactId>provider</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

3.核心配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
    <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
    <dubbo:application name="dubbo" />
    <!-- 使用multicast广播注册中心暴露发现服务地址 -->
    <dubbo:registry  protocol="zookeeper" address="zookeeper://127.0.0.1:2181" />
    <!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
    <dubbo:reference id="userService" interface="com.huilong.service.UserService" />
</beans>



4..然后创建一个测试类用于获取接口具体实现

package com.huilong.service;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * Created by 18358 on 2016/8/10.
 */
public class UserDubboService {

    public static void main(String[] args){
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                    new String[] { "application.xml" });
            context.start();
            UserService userService = (UserService) context.getBean("userService");
            System.out.println(userService.find(15L));
            try {
                System.in.read();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
}
5.运行该方法 从注册中心获取服务,然后查看控制台输出结果:





Dubbo初学者入门手册:全面掌握服务治理与配置 Dubbo是一个高性能、轻量级的Java RPC框架,最初由阿里巴巴开源。它的设计目标是提供一种简洁易用的方式,帮助开发人员构建分布式应用。自2011年开源以来,Dubbo迅速成为国内使用最广泛的分布式服务框架之一。在某些特定的业务场景中,可能需要自定义序列化策略来满足特定需求。Dubbo通过SPI机制允许开发者实现自定义的序列化器。开发者可以继承接口,然后通过目录下的配置文件注册序列化器。 阅读详情

相关推荐

Ubuntu20.04下Intel RealSense D435i相机驱动配置全攻略(含ROS Noetic适配)

本文详细介绍了在Ubuntu20.04系统下配置Intel RealSense D435i相机驱动的完整流程,包括libRealsense SDK 2.0安装、ROS Noetic适配及常见问题解决方案。通过实战指南帮助开发者快速实现深度相机与ROS的集成,适用于机器人视觉和SLAM应用开发。

weixin_29281915的博客 513

Dubbo简单例子一

1、接口定义 package com.dubbo.inter; public interface UserApi {         String sayHello(String name);   } 2、接口实现类定义 package com.dubbo.inter; public class UserApiImpl implements UserApi{

看图说话 699

华中科技大学 计算机组成原理 educoder Logisim平台 计算机数据表示实验

本文主要是对 计算机数据表示实验的笔记和相关Logisim平台的图,供大家学习交流使用。 需要源文件或者源代码,可以留言评论! 目录实验目的第1关:汉字国标码转区位码实验第2关:汉字机内码获取实验第3关:偶校验编码设计第4关:偶校验解码电路设计第5关:16位海明编码电路设计第6关:16位海明解码电路设计第7关:海明编码流水传输实验第8关:16位CRC并行编解码电路设计第9关:CRC编码流水传输实验实验结果: 实验目的 本实训将帮助同学们巩固对计算机中数据表示方法的理解,要求能设计汉字国标码与区位码之间的转换

weixin_48383580的博客 2万+

Dubbo服务的三种启动方式

Dubbo服务的三种启动方式 为什么对于服务提供方的工程,dubbo官方推荐使用可执行jar的方式运行呢,下面对三种启动方式进行比较: 1、 使用web容器(Tomcat、Jetty等)启动dubbo服务 : 增加端口管理复杂性, tomcat/jetty等都需要占用端口,dubbo服务也需要端口;浪费资源(内存),单独启动 tomcat,jetty占用内存大 运用:需要提供web服务的模块,一般...

HsiunKao 1万+

【XR硬件介绍】PICO Space Pro(Project Swan)深度解析:字节 2026 旗舰 MR 头显延期背后

内部代号 Project Swan 的 PICO 年度旗舰 MR 头显正式定名PICO Space Pro,原本计划 2026 年 9 月对外发布,官方官宣推迟至 2026 年第四季度上市。硬件层面已经完成 FCC 认证,硬件成熟度较高,延期核心目标是打磨 PICO OS 6 空间操作系统,补齐空间计算软件能力。本文从产品背景、硬件架构、软件生态、延期逻辑、行业竞争格局几个维度拆解这款国产高端 MR 设备,分析它对国内 XR 产业的意义与待解的问题。

houdou112358的博客 1255

手把手教你用U盘给海信IP501H刷机:GK6323V100C芯片的4.4.2和9.0固件实战

本文详细介绍了海信IP501H电视盒子基于GK6323V100C芯片的刷机实战指南,涵盖Android 4.4.2强刷和Android 9.0免拆刷机两种方案。从工具准备、短接操作到ADB调试,提供全流程解析和常见问题解决方案,帮助用户安全高效地完成刷机操作。

lemon的博客 1459

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.act

Root Cause org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.activiti.rest.service.api.RestResponseFactory' available: expected at least 1 bean which qu

xiongge2005的专栏 2665

【Cadence软件技巧集萃】从Capture到Allergo——分布演示从原理符号导出到网络表

Cadence软件功能多样、性能强大,但是使用起来颇费步骤,尤其是从原理图到网络表的导入步骤,没有经过上手实践还真不一定一次就能搞定哩。本文笔者用将分步演示:1、在Capture软件上绘制原理图;2、将原理图导出网络表;3、在Allergo软件上更新网络表;希望给予使用Cadence的读者有效的帮助1、本文简述了建立Capture项目的步骤,演示了调用元件符号库的方法,并绘制了电气原理图;2、针对加载元件封装库可能遇到的问题,做了排查步骤建议;

qq_33175704的博客 2538

js 判断字符串为空和不为空(两种方法)

1 判断字符串为空 (1)第一种方法 var test=""; if(test==""||test==null||test==undefined){ alert("为空"); } (2)第二种方法 var test=""; if(!test){ alert("为空"); } 2 判断字符串不为空 (1)第一种方法 var test=""; if(test==""||test==null||test==undefined){ alert("为空"); } .

旭东怪的博客 7万+

Balser相机的硬件触发实战:从连线到信号处理

本文详细介绍了Balser相机硬件触发的实战应用,从硬件接线、信号定义到软件配置(Pylon Viewer及API)提供了完整指南。重点阐述了如何利用外部物理电信号实现微秒级精准触发,解决工业场景下的同步与延迟问题,并分享了信号调理、抗干扰等高级实战经验。

y9z0a1b的博客 339

2026年瑞芯微数字IC设计笔试试卷带答案

本文主要考察数字集成电路设计相关知识,包括低功耗设计、时序分析、跨时钟域处理、总线协议等内容。试题分为单选题、多选题、代码设计题和简答题四部分。 单选题涉及门控时钟降低动态功耗、静态时序分析的限制、跨时钟域同步方案、时序违例修复方法、AHB总线信号、异步FIFO设计、半导体工艺电阻特性、二进制数转换、同步/异步复位比较以及分频电路设计等知识点。 多选题重点考查动态功耗优化技术、亚稳态特性、异步FIFO设计规范、Verilog可综合代码编写要求以及AXI总线协议特点等。 代码设计题要求实现一个同步FIFO和3

Open 217

dubbo初学 dubbo整合zookeeper

初学dubbo,踩了很多坑,网上的文章真的就没有能用的,害,记录一下 适合初学者阅读 首先zookeeper是肯定要装好的,zookeeper如果我们装在阿里云服务器上,记得关闭防火墙与在安全组中打开相应端口 关闭防火墙 systemctl disable firewalld 查看防火墙状态 systemctl status firewalld 定义个父工程 pom <parent> <groupId>org.springframework.boot</gro

fancy的博客 2325

手把手教你学simulink(32.1)--汽车电动机管理场景示例:基于Simulink的发动机管理系统中的混合动力车辆能量管理优化

本项目旨在设计和实现一个用于混合动力车辆(Hybrid Electric Vehicle, HEV)的能量管理优化系统(Energy Management Optimization System, EMOS)。通过Simulink进行建模和仿真,确保系统的稳定性和性能。该系统采用了先进的控制策略,如模型预测控制(MPC)、模糊逻辑控制、自适应控制等,以优化燃油经济性、减少排放,并提高驾驶体验。

MHD0815的博客 187

Dubbo--dubbo-admin

其他网址

IT利刃出鞘的博客 4907

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

dubbo+zookeeper配置及使用

dubbo:service interface=“接口的全限定名[com.xyh.service.TestService]” ref=“testServiceImpl[实现类对象]” timeout=“600000” />工程中需要添加dubbo依赖的jar包,zookeeper以及zookeeper的客户端zkclient。如果遇到启动了 但是查看状态的时候说没启动的时候,吧data里面的pid文件删除 重启ok。...

m0_67393413的博客 930

计算机控制技术及应用

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

dubbo项目实战代码展示

dubbo-client项目看上去和平常项目没什么区别,只是多了一个dubbo的配置文件,用于订阅dubbo服务而已,当然dubbo-clien。提取出来放在dubbo-domain中,dubbo-web存放的是dubbo的对外接口的实现和dubbo的生产者的配置信息。好了,整个dubbo的服务以及完成了,稍后会将使用的代码上传到GIT上,到时候如果有需要的看客可以自己去查看,我也只是。dubbo的对外接口,只是接口的定义和基础实体类已经一些公共工具类,如果你想做的更细,可以把基础实体类和公共工具类。...

m0_54866636的博客 668

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

springboot+dubbo+zookeeper(微服务生产者与消费者实战)

一,生产者配置: 1,导入依赖 <!-- dubbo --> <dependency> <groupId>io.dubbo.springboot</groupId> <artifactId>spring-boot-starter-dubbo</artifactId> <v...

weixin_42533856的博客 827

Dubbo服务配置的两种方式

http://www.cnblogs.com/zdd-java/archive/2017/03/17/dubbo2.html

393

dubbo学习笔记(一)——dubbo的作用及简单应用

dubbo的简单运用

飞!!!的博客 4046

【Dubbo】Dubbo开发遇到问题记录

user-guide:http://dubbo.io/User+Guide-zh.htm 简单记录下过程和需要注意的地方: 我的环境和工具:jdk1.7 win10 Eclipse Mar tomcat7.0.69 1.下载并安装zookeeper,解压出来后,将conf文件下的zoo_sample.cfg复制一份更名为zoo.cfg,因为启动是zookeeper需要此文件。启动:cm...

极客中年的博客 571

【dubbo在SSM中进行配置问题】

dubbo在SSM项目中进行配置

qq_54141095的博客 308

java-dubbo接口测试三种方式

jmeter-plugins-dubbo-2.7.3.jar,jmeter-plugins-dubbo-2.7.3-with-dependencies.jar.2.2 将jmeter-plugins-dubbo-2.7.3-with-dependencies.jar包放入${JMETER_HOME}libext路径下,重启jmeter即可。重命名:conf/zoo_sample.cfg为zoo.cfg(记住端口号)(2) 添加–》取样器 --》dubbo sample。###显示服务的方法列表。...

web15185420056的博客 996

DUBBO配置

1.服务端配置: <!-- 1.配置服务端应用名, 用于计算依赖关系,与客户端应用名不一致--> <dubbo:application name="ls-manager-service" /> <!-- 2.1配置暴露服务的广播地址及端口 ,组播地址可以为224.0.0.0至235.255.255.255--> <!-- <dubbo:regis...

luking的博客 361

zookeeper安装,springboot发布Dubbo服务

前提是先把zookeeper安装好,参考博客: zookeeper安装 1.添加依赖 首先创建一个maven项目dubbo-demo-provider pom.xml加入依赖: <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version&g

可控的事情要谨慎,不可控的事情要乐观。 271

springboot + dubbo + zookeeper集群

准备工作:zookeeper集群部署https://blog.youkuaiyun.com/DavidSoCool/article/details/96431181 创建一个maven-archetype-quickstart 一直next,工程名和Artifactid一样就行了,直接finish 项目结构: 在新建一个maven-archetype-quickstart,用做接口jar...

DavidSoCool的博客 5697
上一篇: 使用git命令 (git reset --hard HEAD) 回退版本信息
下一篇: Duplicate spring bean id “XXXXX”
Java_HuiLong
博客等级 码龄11年 26粉丝 59原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值