使用dubbo搭建分布式项目

【传感器标定(三):激光雷达标定原理与实现详解】 本文系统介绍了激光雷达标定的基本原理与方法。主要内容包括:激光雷达标定的分类(内参标定和外参标定)、坐标系定义和刚体变换数学基础;详细阐述了测距误差和光束方向两种内参标定方法;重点分析了基于目标(平面标定板、三维标定物)和基于运动(手眼标定、点云配准)的外参标定方法;介绍了多传感器联合标定技术及非线性优化、鲁棒标定等实现方法;最后提出了定量和定性两种标定评估体系。为激光雷达在自动驾驶等领域的精确应用提供了系统的标定技术指导。 阅读详情

dubbo概述

Dubbo 是一个分布式服务框架,阿里巴巴开源项目,被国内电商及互联网项目中使用。

Dubbo 致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案。简单的说,Dubbo就是个服务框架,如果没有分布式的需求,其实是不需要用的,只有在分布式的时候,才有Dubbo这样的分布式服务框架的需求,并且本质上是服务调用,是一个远程服务调用的分布式框架。
在这里插入图片描述
节点角色说明:
• Provider: 暴露服务的服务提供方。
• Consumer: 调用远程服务的服务消费方。
• Registry: 服务注册与发现的注册中心。
• Monitor: 统计服务的调用次调和调用时间的监控中心。
• Container: 服务运行容器。
调用关系说明:
• 0. 服务容器负责启动,加载,运行服务提供者。
• 1. 服务提供者在启动时,向注册中心注册自己提供的服务。
• 2. 服务消费者在启动时,向注册中心订阅自己所需的服务。
• 3. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推
送变更数据给消费者。
• 4. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,
如果调用失败,再选另一台调用。
• 5. 服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计
数据到监控中心。
Zookeeper 介绍
官方推荐使用 zookeeper 注册中心。注册中心负责服务地址的注册与查找,相当于目录服务,服务提供者和消费者只在启动时与注册中心交互,注册中心不转发请求,压力较小。
Zookeeper 是 Apacahe Hadoop 的子项目,是一个树型的目录服务,支持变更推送,适合作为Dubbo 服务的注册中心,工业强度较高,可用于生产环境。

idea搭建项目流程

在这里插入图片描述
创建如上图所示的项目结构目录,其中record_manager_web和record_service为web项目,父工程为pom工程,其他项目默认为jar工程

在父工程的pom文件中添加依赖信息和版本号

数据访问模块(record_dao)的依赖
对于自己创建的项目只依赖pojo

通用实体类模块(pojo)不需要依赖信息

服务接口模块仅需要依赖pojo

服务模块需要依赖自己的有common、dao和interface其中pojo已经被dao依赖,所以不需要重复依赖

manager_web模块需要依赖自己项目的common和interface,服务(service)通过远程调用实现注入

common项目只需要依赖本项目所需的依赖

详细依赖信息见详细依赖

配置dubbo远程调用相关

在类上加注解都是基于dubbo的注解
dao项目的配置

在这里插入图片描述
db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/youlexuandb?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

log4j.properties配置

# global level
log4j.rootLogger = error,stdout

#MyBatis logging configuration
# self package level
log4j.logger.com.offcn=debug


log4j.appender.stdout = org.apache.log4j.ConsoleAppender
# standard ouput for black, System.err is red
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =%d{HH\:mm\:ss} %5p %c - %m%n

my-batis.xml配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

	<settings>
	   	<setting name="logImpl" value="LOG4J"/>
	</settings>

	<plugins>
		<plugin interceptor="com.github.pagehelper.PageInterceptor">
			<!-- 设置数据库方言类型:oracle, mysql -->
			<property name="helperDialect" value="mysql"/>
		</plugin>
	</plugins>
	
</configuration>

spring-dao.xml配置

<?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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans.xsd 
    		http://www.springframework.org/schema/context 
    		http://www.springframework.org/schema/context/spring-context.xsd">

	<!-- 加载配置文件 -->
	<context:property-placeholder location="classpath:db.properties" />

	<!-- 数据库连接池 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
		destroy-method="close">
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="maxActive" value="10" />
		<property name="minIdle" value="5" />
	</bean>

	<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="configLocation" value="classpath:mybatis-cfg.xml" />
		<property name="mapperLocations" value="classpath:com/weilinyang/mapper/*Mapper.xml" />
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.weilinyang.mapper" />
	</bean>

</beans>

service服务项目的配置
在这里插入图片描述
web.xml配置:在classpath要加*
在这里插入图片描述
classpath后边的*表示将本项目中依赖项目的以spring-开头的xml文件进行加载,如service依赖了dao,就会把dao项目中的spring-dao.xml加载进去
spring-service-application.xml的配置:

<?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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--扫描包-->
    <context:component-scan base-package="com.weilinyang"/>
    <!--配置事务-->
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <tx:advice id="crudAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true" />
            <tx:method name="select*" read-only="true" />
            <tx:method name="list*" read-only="true" />
            <tx:method name="query*" read-only="true" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="*" propagation="REQUIRED" />
        </tx:attributes>
    </tx:advice>

    <aop:config>
        <aop:pointcut expression="execution(* com.weilinyang.service..*.*(..))"
                      id="pointcut" />
        <aop:advisor advice-ref="crudAdvice" pointcut-ref="pointcut" />
    </aop:config>

</beans>

spring-service-dubbo.xml的配置:

<?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:protocol name="dubbo" port="20881"/>

    <!-- 提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="record_service" />

    <!-- 向zk注册服务 -->
    <dubbo:registry address="zookeeper://192.168.2.123:2181" />

    <!-- 扫描带service注解的类 -->
    <dubbo:annotation package="com.weilinyang.service.impl" />

</beans>

manager_web服务项目的配置
manager_web项目是web服务,主要对外访问不涉及业务实现,不用配置application.xml,仅需配置spring-mvc.xml
在这里插入图片描述

web.xml的配置:classpath后不加*,web项目不依赖本地服务,是通过dubbo远程调用

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xmlns="http://xmlns.jcp.org/xml/ns/javaee"
		 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
		 id="WebApp_ID" version="3.1">

	<!-- 避免spring查找WEB-INF/applicationContext.xml -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring-*.xml</param-value><!--classpath后不加*,web项目不依赖本地服务,是通过dubbo远程调用-->
	</context-param>

	<!-- springMVC拦截 -->
	<servlet>
		<servlet-name>spMVC</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring-mvc.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>spMVC</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

	<!-- springMVC编码过滤 -->
	<filter>
		<filter-name>charset</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>utf-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>charset</filter-name>
		<url-pattern>*.do</url-pattern>
	</filter-mapping>

</web-app>

spring-dubbo.xml的配置:

<?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:protocol name="dubbo" port="20881"/>

    <!-- 提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="record_manager_web" />

    <!-- 向zk注册服务 -->
    <dubbo:registry address="zookeeper://192.168.2.123:2181" />

    <!-- 扫描带controller注解的类 -->
    <dubbo:annotation package="com.weilinyang.manager.controller" />

</beans>

spring-mvc.xml的配置:

<?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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context
    		http://www.springframework.org/schema/context/spring-context.xsd
    		http://www.springframework.org/schema/mvc
    		http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- 注解包扫描 -->
    <context:component-scan base-package="com.weilinyang" />

    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean
                    class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
                <property name="supportedMediaTypes" value="application/json" />
                <property name="features">
                    <array>
                        <value>WriteMapNullValue</value>
                        <value>WriteDateUseDateFormat</value>
                    </array>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <!-- 静态资源处理 -->
    <mvc:default-servlet-handler />


</beans>

群晖Git Server权限配置全攻略:如何让普通用户(非admin)也能安全提交代码? 本文详细解析了群晖Git Server权限配置方案,特别针对普通用户(非admin)安全提交代码的需求。通过SSH服务配置、精细化用户权限管理及仓库创建自动化脚本,实现在DS218+等群晖NAS设备上的高效代码协作,同时确保系统安全。 阅读详情

相关推荐

CCC数字钥匙3.0标准解读(22)

介绍设备制造商服务器和车辆制造商服务器之间的通信协议.

weixin_41738640的博客 1748

分布式--使用Dubbo搭建分布式项目

在分布式架构中,我们会将不同功能模块化,部署到不同的服务器上,这时不同模块之间的通讯就由RPC框架完成,上次介绍了Dubbo的基本使用,知道了它基于Spring容器,因此在SpringBoot项目中可以很方便的使用 一、项目配置 还是利用经典的oracle部门员工表,MyBatis--初入MyBatis中可以找到创建表和数据的sql,实现mapper层和service层的分布式架构 项目依赖关系如...

aruba的博客 1910

OmniQuant:全方位校准实现大语言模型高效量化与移动端部署

模型量化是一种通过降低模型权重和激活值的数值精度来压缩模型大小、减少内存占用和计算开销的核心技术。其原理在于将高精度浮点数映射到低精度整数表示,从而在保持模型性能的同时,显著提升存储和计算效率。这项技术的价值在于,它使得大规模语言模型能够在消费级硬件和资源受限的移动设备上运行,极大地拓宽了AI应用场景。OmniQuant作为一项前沿的量化技术,通过引入可学习权重裁剪和可学习等价变换机制,实现了对权重分布不均匀和激活值异常值问题的协同优化,从而在极低的比特数下仍能保持优异的模型性能。本文深入探讨了OmniQu

weixin_30719711的博客 482

dubbo分布式服务框架入门

目录 1.dubbo简介 2.dubbo架构 3.dubbo搭建 3.1本地本地搭建service和web模块 3.2dubbo搭建 3.3优化dubbo搭建 本文参考b站黑马程序员dubbo入门课程 视频连接:https://www.bilibili.com/video/BV1VE411q7dX?p=1 1.dubbo简介 Dubbo是阿里巴巴公司开源的一个高性能、轻量级的JavaRPC框架,致力于提供高性能和透明化 的RPC远程服务调用方案,以及SOA服务治理方案 dubbo

雪月清的博客 5165

STK与Matlab连接报错?手把手教你解决mexConnect函数执行问题(附完整避坑指南)

本文针对STK与Matlab连接时常见的“mexConnect函数执行”报错,提供了完整的诊断与解决方案。文章深入剖析了错误根源在于路径冲突或文件损坏,并手把手指导用户通过定位STK连接器文件、正确配置Matlab路径(包括使用addpath命令)以及执行初始化测试三步走策略,彻底解决问题。同时附上版本兼容性检查、安装避坑指南及构建稳健工作流的建议,帮助用户建立可靠的STK-Matlab联合仿真环境。

yolo5detector的博客 472

SCCM部署教程:(3)SCCM安装

这两则摘要介绍了WSUS和SCCM的安装步骤: WSUS安装:通过服务器管理器添加"Windows服务器更新服务"角色,选择SQL数据库并指定安装路径,验证数据库连接后完成安装。 SCCM安装:先运行预检工具Prereqchk.exe,选择主站点安装类型,配置语言、站点代码和名称,设置SQL数据库连接参数(保留默认端口4022),选择通信方法和系统角色(管理点和分发点),最后完成约1小时的安装过程。 两则安装指南都强调要确保数据库配置与前期准备一致,并提供了关键配置选项的说明。

小V锅的专栏 893

如何用Spring Boot 整合Dubbo + Zookeeper 实现分布式

RPC【Remote Procedure Call】是指远程过程调用,是一种进程间通信方式,他是一种技术的思想,而不是规范。它允许程序调用另一个地址空间(通常是共享网络的另一台机器上)的过程或函数,而不用程序员显式编码这个远程调用的细节。即程序员无论是调用本地的还是远程的函数,本质上编写的调用代码基本相同。基于SpringBoot项目整合Dubbo + Zookeeper 实现消费者消费服务提供者的服务消费者为订单模块。

xxxzzzqqq_的博客 1111

新能源车主必看:用高德API+充电站数据制作跨城出行充电规划工具(附完整代码)

本文为新能源车主提供了一份详细的跨城出行充电规划工具构建指南。通过整合高德地图API与充电站数据,手把手教你使用Python开发一个智能规划系统,可自动规划路线并推荐沿途充电站,有效缓解里程焦虑。文章包含完整代码、核心算法解析及可视化实现,帮助车主实现个性化、高效的出行规划。

tgb3456789的博客 898

Dubbo介绍

介绍Dubbo背景 大规模服务化之前,应用可能只是通过RMI或Hessian等工具,简单的暴露和引用远程服务,通过配置服务的URL地址进行调用,通过F5等硬件进行负载均衡。 (1) 当服务越来越多时,服务URL配置管理变得非常困难,F5硬件负载均衡器的单点压力也越来越大。 此时需要一个服务注册中心,动态的注册和发现服务,使服务的位置透明。 并通过在消费方获取服务提供方地址列表,实现软负载均衡和Failover,降低对F5硬件负载均衡器的依赖,也能减少部分成本。 (2) 当进一步发展,服务间依赖关系变得错踪复

qq_44918331的博客 305

影刀RPA之成绩批量查询系统

自动化登录账号,读取数据表中内容去填写信息去查询,并判断多个数据不同的页面去不同的读取查询结果内容,如考生各项信息与各科成绩,总分和查询时间,采集出来到指定的数据表格中,等待时间并依次循环运行。主要功能。

2201_75330891的博客 1082

Qt Installer Framework 简单使用

qt installer framework 简单使用

qq_42815643的博客 2574

dubbo 实现简易分布式服务

dubbo 实现简易分布式服务

个人学习使用 1540

DISK配置服务器软RAID工作任务(RAID1+BITLOCKER)-winserver4

DISK配置服务器软RAID工作任务(RAID1+BITLOCKER)-winserver4

新时代先锋的博客 7297

分布式项目新选择:Dubbo搭建方案

Dubbo最初由阿里巴巴内部开发,并于2011年开源。它不仅提供了基本的RPC功能,还涵盖了服务注册与发现、负载均衡、容错处理、监控统计等丰富的服务治理功能。Dubbo的核心架构包括提供者(Provider)、消费者(Consumer)、注册中心(Registry)和监控中心(Monitor)四个关键角色,它们之间通过Dubbo提供的通信协议进行通信,实现了服务的注册、发现、调用和监控。

md_1008的博客 984

计算机控制技术及应用

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

深度学习工具包 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+Maven+IDEA搭建分布式项目实战

一、名词解释(来源百度百科): Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。 Dubbo(读音[ˈdʌbəʊ])是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成。 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一...

群鸿 6138

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

使用Spring Boot+Dubbo+Zookeeper搭建第一个分布式项目(详细介绍如何搭建分布式项目,下篇)

一、概述 上一篇讲解了搭建定义接口项目和服务提供者项目,这篇主要讲解如何搭建服务消费者项目。 二、搭建步骤 步骤一:创建服务消费者项目,创建一个名为 hello-dubbo-service-user-consumer 的Maven项目,该项目只负责定义接口,创建好项目后如下图所示。 步骤二:在pom.xml下添加以下配置。 <dependencies> <dep...

weixin_42146366的博客 2927

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Maven + Zookeeper + Dubbo 搭建简单分布式项目

前言:对于第一次接触分布式dubbo框架的小伙伴,可先自行了解一下dubbo的相关原理和运行机制。博主推荐一篇不错的博文,小伙伴们可以阅览后,再学习本文dubbo分布式项目搭建。 dubbo基本原理:https://blog.youkuaiyun.com/en_joker/article/details/89946034 本文借鉴以下博客:Dubbo入门---搭建一个最简单的Demo框架 1. Zook...

Layduo 500

zookeeper+dubbo分布式项目搭建

1,将单一的java web项目 拆分成  公共接口API  数据交互层service, 访问层web 2,zookeeper  dubbo 分布式环境:zookeeper  3台,一般是将项目中的不同业务 拆分成多个service ,然后拆分的service 可以放置多台机器,做灾备 3,zookeeper 启动 命令行启动方式:  直接回车 就启动 了,验证启动结果

微阳潋潋落寒汀的博客 515

【项目实战】zookeeper+dubbo搭建分布式项目

正如标题所言,这篇文章来介绍一下我是怎么使用zookeeper+dubbo成功搭建一个分布式项目的。

stillaliveQEJ的博客 588

SpringBoot+Dubbo+Zookeeper搭建分布式项目练习

SpringBoot+Dubbo+Zookeeper分布式项目练习(1) 由于一台服务器的能力有限,所以越来越多的大型项目采用分布式的布置方式,多台服务器共同去完成一个大型的集成服务。对分布式的练习还是很有必要的。 这个项目练习主要是使用SpringBoot、Dubbo和Zookeeper来完成一个分布式的项目练习,目标是多个服务器提供一套服务的多个模块,客户端通过网页进行数据的读取等功能。本项目是个人设计的一个练习项目,不可能一蹴而就的,需要多次的迭代,每次增加一些小功能,最后完成一个大项目。本文主要是项

LostCatDragon的博客 584

SpringBoot分布式taotao商城框架搭建-非dubbo项目

SpringBoot分布式taotao商城框架搭建-非dubbo项目 SpringBoot+SpringDataJPA+IDEA 先期准备 MySql安装好 IDEA maven 在新建工程之前需要安装MySql并新建数据库:taotao 然后新建一个叫tb_user的表: create table tb_user ( id bigint auto_increm...

Brian的博客 402

dubbo+zookeeper 分布式项目搭建

dubbo简介:            系统间服务调用方式有三种,浏览器直接访问,通过ajax或者jsonp方式请求。第二种,httpclient方式发起http协议的请求,是后台调用。第三种基于RPC方式的远程过程调用协议的请求。DUBBO是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,0

周洲 (Julie) 1万+

使用Spring Boot+Dubbo+Zookeeper搭建第一个分布式项目(详细介绍如何搭建分布式项目,上篇)

一、概述 最近学习了PRC分布式服务框架-Dubbo,然后结合之前所学的Spring Boot和Zookeeper来搭建一个Hello Dubbo 分布式服务项目样例。 我们分上篇和下篇进行讲解,此篇是讲解如何搭建API项目已经服务提供者项目。 二、搭建步骤 步骤一:创建服务接口项目,创建一个名为 hello-dubbo-service-user-api 的Maven项目,该项目只负责定义接口...

weixin_42146366的博客 3385

dubbo+zookeeper对比springCloud及分布式项目搭建详解

引言   dubbo是阿里巴巴自主研发的RPC框架,全称”Remote Procedure Call”,从字面意思上也很好理解,即远程过程(服务)调用,主要作用是用于应用之间的解耦,调用远程服务。dubbo和springCloud不同,dubbo使用的是原生的RPC技术来进行服务调用,而springCloud则应用了rest Api,相比之下,前者性能较高,后者则牺牲性能换来了架构的灵活,并且sp...

小螺旋丸的博客 4303

dubbo 搭建分布式项目

原理我就不解释了,先百度下。在搭建之前,我们先把zookeeper启动,挂在那里。zookeeper的搭建很简单,请参考:https://blog.youkuaiyun.com/shushugood/article/details/808030441.服务提供方1.1 先创maven项目1.2 把pom.xml 配置改了, 把相关的包,让其自动下载完,&lt;project xmlns="http://mav...

老农民挖数据 2559

SpringBoot+Dubbo搭建简单分布式项目

本文参考以下文章,搭建了一个分布式的demo,加强对分布式以及RPC的理解。 超详细,新手都能看懂 !使用SpringBoot+Dubbo 搭建一个简单的分布式服务 总结为以下几点: RPC是位于不同服务器的服务,之间的相互调用。 Dubbo是实现分布式服务的工具,用于提供不同的服务,如消费者服务,提供者服务。Zookeeper是分布式服务的管理中心,提供者在此处注册服务,消费者在此处订阅服务。消费者要调用提供者的方法,用于自己使用。 项目架构为: 云服务器上安装zookeeper,并开启相应的服务,

qq_41558341的博客 473
上一篇: duubo分布式项目得依赖信息
下一篇: spring整合mybatis配置sqlSessionFactory时是否要配置mapperLocations
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值