Jetson Orin Nano - SONY imx415 camera驱动开发

VIPJetson Orin Nano - SONY imx415 camera驱动开发
基于英伟达 Jetson orin nano 平台 imx415 camera驱动开发
开通可读全文 ·3.2k 人阅读
最低0.47元/天 解锁文章

目录

前言:

调试准备工作:

修改内核默认打印等级

一、imx415驱动开发

1、硬件接线

2、设备树修改

2.1 创建 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi 文件

2.2 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi 添加到设备树

2.3 编译设备树

3、imx415驱动开发

3.1 imx415寄存器

1)mclk 时钟

2)lane数量

3)lane速率

4)分辨率

5)像素深度

6)Master/Slave模式

7)启流、停流相关

8)增益

​编辑

9)曝光

​编辑

10)All pixel模式 4lane 配置表

3.2 imx415驱动

1)Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/imx415_mode_tbls.h 源码

2)Linux_for_Tegra/source/nvidia-oot/include/media/imx415.h 源码

3)Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/nv_imx415.c 驱动文件

4)将 nv_imx415 添加到Makefile

二、编译调试

1、编译imx415驱动

2、安装 v4l-utils 并查看 /dev/video0信息

2.1 安装 v4l-utils

2.2 查看 /dev/video0 信息

3、抓拍

3.1 v4l2-ctl 命令验证vi抓拍

3.2 gstreamer英伟达命令抓拍

1)gst-launch-1.0 自动曝光、自动增益抓拍

2)gst-launch-1.0 设置曝光、增益抓拍

三、imx415驱动开发遇到的问题及解决方法

1、Jetson orin nano开发板的CAM0不支持4lane模式

2、使用 CSI0/1 时,需要将lane_polarity改为 6

3、v4l2-ctl 抓图命令报错

4、v4l2-ctl 抓图不成功,vi能收到数据,但数据不对

5、gstreamer抓图偏红色

四、曝光、增益、格式、焦距对拍照效果的影响


前言:

nvidia相机开发参考链接:相机软件开发解决方案 — NVIDIA Jetson Linux 开发者指南

可加载内核模块 (LKM)其实就是就是编译成ko模块。nvidia将所有模块都放在 nvidia-oot 目录下。参考链接:传感器软件驱动程序编程 — NVIDIA Jetson Linux 开发者指南

说明:博主使用野火的imx415摄像头模块,在 Jetson Orin Nano开发板上开发imx415驱动

调试准备工作:


修改内核默认打印等级

$ vi /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
kernel.printk = 8 8 8 8                #打印等级

###################################################################
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/

一、imx415驱动开发


1、硬件接线

imx415模块和 Jetson orin nano开发板的csi接口中间有转接板。2 lane模式下,仅 CSI_D0 P/N 和 CSI_D1 P/N 有数据。我使用的是 4 lane 模式。

硬件接上后,用 i2cdetect 工具探测 I2C通不通。cam_i2cmux挂在i2c3下,因此命令如下:

$ i2cdetect -r -y 2

可以看到 imx415 的设备地址为 0x1a

问题:如何知道 CAM1_I2C 挂在 i2c3下?

查看 Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public/tegra234.dtsi

cam_i2c 为I2C3节点, 因此cam_i2cmux在I2C3节点下

2、设备树修改

设备树增加sensor参考文档:Sensor Software Driver Programming — NVIDIA Jetson Linux Developer Guide

2.1 创建 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi 文件

1)将 Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public/overlay 目录下的 tegra234-p3767-camera-p3768-imx477-C.dts 作为模板拷贝一份 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi

imx415 模块 4 lane差分线接在CSI2上,CSI2对应"serial_c"(CSI0对应serial_a,依此类推),因此命名 "tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi"

2)修改 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi

关键参数计算过程:

  • compatible = "ridgerun,imx415" 要和imx415驱动对应上

  • mclk_khz:imx415模块外接 37.125M晶振,因此 mclk_khz = "37125"

  • 4 lane模式:因此 num_lanes = "4", bus-width = <4>;

  • CSI2:因此 tegra_sinterface = "serial_c",port-index = <2>

  • 分辨率:根据 imx415分辨率设置 "active_w = 3864",active_h = "2192"

  • pixel_phase:像素格式,pixel_phase = "gbrg",调试时设置为 "rggb" 导致图像偏红色

  • csi_pixel_bit_depth:像素深度,imx415使用RAW12模式,因此 csi_pixel_bit_depth = "12"

  • pix_clk_hz:imx415 配置 lane频率为 891 Mbps,4lane,像素深度为12bit,pix_clk_hz = 891 Mbps × 4 / 12 = 297000000,我理解只要不小于此值即可。

  • mclk_multiplier :mclk_multiplier  ≥ pix_clk_hz / mclk = 297000000 / 37125000 = 8,因此mclk_multiplier = "8"。从nvidia官方手册可知,mclk_multiplier 必须大于等于pix_clk_hz / mclk,以确保ISP运行得足够快,能够处理来自传感器的数据。

  • 增益,查看imx415手册

 GAIN_PCG_0计算公式:GAIN_PCG_0 = Gain[dB] x 10 /3

GAIN_PCG_0 范围为 0 - 240d,因此 Gain范围为  0 - 72 [dB],我这里增益因子配置为 gain_factor = "10" ,Gain范围 0 - 72 [dB] 乘上增益因子,得到 min_gain_val = "0", max_gain_val = "720",step为 0.3dB 乘增益因子,因此 step_gain_val = "3"

  • 曝光:

曝光参数单位为us,需要根据帧率(30fps)、VMAX(2250)、 SHR0 值范围(8 到 Number oflines per frame - 4),按照下面公式倒推 exposure 最小值、最大值、step,我算得结果图下:

min_exp_time = "15";        /* 单位:us */
max_exp_time = "33214";     /* 单位:us */
step_exp_time = "15";       /* 单位:us */

  • embedded_metadata_height:根据imx415手册来配置为 "1",如下图

最终 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi 文件内容如下:

设备树描述了 VI(视频输入)、NvCSI 、传感器模块 的端口绑定关系

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

///dts-v1/;
///plugin/;

#define CAM0_RST	TEGRA234_MAIN_GPIO(Q, 6)	/* add */
#define CAM0_PWDN	TEGRA234_MAIN_GPIO(H, 6)
#define CAM1_PWDN	TEGRA234_MAIN_GPIO(AC, 0)
#define CAM_I2C_MUX 	TEGRA234_AON_GPIO(CC, 3)

#include <dt-bindings/tegra234-p3767-0000-common.h>

/ {
	overlay-name = "Camera IMX415-C 4 lane";
	jetson-header-name = "Jetson 24pin CSI Connector";
	compatible = JETSON_COMPATIBLE_P3768;
	/*IMX415 connected on cam0 port */

	fragment@0 {
		target-path = "/";
		__overlay__ {
			tegra-capture-vi  {
				num-channels = <1>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						rbpcv3_imx415_vi_in1: endpoint {
							port-index = <2>;
							bus-width = <4>;
							remote-endpoint = <&rbpcv3_imx415_csi_out1>;
						};
					};
				};
			};
			tegra-camera-platform {
				compatible = "nvidia, tegra-camera-platform";
				/**
				* Physical settings to calculate max ISO BW
				*
				* num_csi_lanes = <>;
				* Total number of CSI lanes when all cameras are active
				*
				* max_lane_speed = <>;
				* Max lane speed in Kbit/s
				*
				* min_bits_per_pixel = <>;
				* Min bits per pixel
				*
				* vi_peak_byte_per_pixel = <>;
				* Max byte per pixel for the VI ISO case
				*
				* vi_bw_margin_pct = <>;
				* Vi bandwidth margin in percentage
				*
				* max_pixel_rate = <>;
				* Max pixel rate in Kpixel/s for the ISP ISO case
				*
				* isp_peak_byte_per_pixel = <>;
				* Max byte per pixel for the ISP ISO case
				*
				* isp_bw_margin_pct = <>;
				* Isp bandwidth margin in percentage
				*/
				num_csi_lanes = <4>;
				max_lane_speed = <1500000>;
				min_bits_per_pixel = <10>;
				vi_peak_byte_per_pixel = <2>;
				vi_bw_margin_pct = <25>;
				max_pixel_rate = <7500000>;
				isp_peak_byte_per_pixel = <5>;
				isp_bw_margin_pct = <25>;
				/**
				 * The general guideline for naming badge_info contains 3 parts, and is as follows,
				 * The first part is the camera_board_id for the module; if the module is in a FFD
				 * platform, then use the platform name for this part.
				 * The second part contains the position of the module, ex. "rear" or "front".
				 * The third part contains the last 6 characters of a part number which is found
				 * in the module's specsheet from the vendor.
				 */
				modules {
					module1 {
						badge = "jakku_rear_RBPCV3";
						position = "rear";
						orientation = "1";
						drivernode0 {
							pcl_id = "v4l2_sensor";
							sysfs-device-tree = "/sys/firmware/devicetree/base/bus@0/cam_i2cmux/i2c@1/rbpcv3_imx415_c@1a";
						};
					};
				};
			};
			bus@0 {
				host1x@13e00000 {
					nvcsi@15a00000 {
						num-channels = <1>;
						#address-cells = <1>;
						#size-cells = <0>;
						channel@0 {
							reg = <0>;
							ports {
								#address-cells = <1>;
								#size-cells = <0>;
								port@0 {
									reg = <0>;
									rbpcv3_imx415_csi_in1: endpoint@0 {
										port-index = <2>;
										bus-width = <4>;
										remote-endpoint = <&rbpcv3_imx415_out1>;
									};
								};
								port@1 {
									reg = <1>;
									rbpcv3_imx415_csi_out1: endpoint@1 {
										remote-endpoint = <&rbpcv3_imx415_vi_in1>;
									};
								};
							};
						};
					};
				};
				cam_i2cmux {
					status = "okay";
					compatible = "i2c-mux-gpio";
					#address-cells = <1>;
					#size-cells = <0>;
					mux-gpios = <&gpio_aon CAM_I2C_MUX GPIO_ACTIVE_HIGH>;
					i2c-parent = <&cam_i2c>;
					i2c@0 {
						rbpcv2_imx219_a@10 {
							status = "disabled";
						};
					};
					i2c@1 {
						status = "okay";
						reg = <1>;
						#address-cells = <1>;
						#size-cells = <0>;
						rbpcv2_imx219_c@10 {
							status = "disabled";
						};
						rbpcv3_imx415_c@1a {
							reset-gpios = <&gpio CAM1_PWDN GPIO_ACTIVE_HIGH>;
							compatible = "ridgerun,imx415";
							/* I2C device address */
							reg = <0x1a>;
							/* V4L2 device node location */
							devnode = "video0";
							/* Physical dimensions of sensor */
							physical_w = "9.3";
							physical_h = "4.65";
							sensor_model = "imx415";
							use_sensor_mode_id = "true";
							mode0 { /* IMX415_MODE_3864x2192 */
								mclk_khz = "37125";	//"24000";
								num_lanes = "4";
								tegra_sinterface = "serial_c";
								phy_mode = "DPHY";
								discontinuous_clk = "no";
								dpcm_enable = "false";
								cil_settletime = "0";		// 0表示自动校准 
								lane_polarity = "0";
								active_w = "3864";
								active_h = "2192";
								mode_type = "bayer";
								pixel_phase = "gbrg";	//"rggb";
								csi_pixel_bit_depth = "12";	//12
								readout_orientation = "0";	//90
								line_length = "4400";	//0x08CA "11200";
								inherent_gain = "1";
								mclk_multiplier = "8";		//pix_clk_hz / mclk_khz = 297000000 / 37125000 = 8
								pix_clk_hz = "297000000";	//891 Mbps × 4 / 12
								gain_factor = "10";
								framerate_factor = "1000000";
								exposure_factor = "1000000";
								min_gain_val = "0";	/* 0dB */
								max_gain_val = "720";	/* 72dB */
								step_gain_val = "3";	/* 0.3dB step */
								default_gain = "10";	/* 1dB */
								min_hdr_ratio = "1";
								max_hdr_ratio = "1";
								min_framerate = "2000000"; /* 2.0 fps */
								max_framerate = "60000000";	//"30000000"; /* 30.0 fps */
								step_framerate = "1";
								default_framerate = "30000000"; /* 30.0 fps */
								min_exp_time = "15";		/* us, 1H时间 = line_length / pix_clk_hz */
								max_exp_time = "33214";	//"33334";		/* us */
								step_exp_time = "15";
								default_exp_time = "5000";	/* us */
								embedded_metadata_height = "1";	
								set_mode_delay_ms = "500";                      //dongao 等待8帧
							};
							mode1 { /* IMX415_MODE_3864x2192 */
								mclk_khz = "37125";	//"24000";
								num_lanes = "4";
								tegra_sinterface = "serial_c";
								phy_mode = "DPHY";
								discontinuous_clk = "no";
								dpcm_enable = "false";
								cil_settletime = "0";		// 0表示自动校准 
								lane_polarity = "0";
								active_w = "3864";
								active_h = "2192";
								mode_type = "bayer";
								pixel_phase = "gbrg";	//"rggb";
								csi_pixel_bit_depth = "12";	//10
								readout_orientation = "0";	//90
								line_length = "4400";	//0x08CA "11200";
								inherent_gain = "1";
								mclk_multiplier = "8";
								pix_clk_hz = "297000000";		//"356400000";
								gain_factor = "10";
								framerate_factor = "1000000";
								exposure_factor = "1000000";
								min_gain_val = "0";	/* 0dB */
								max_gain_val = "720";	/* 72dB */
								step_gain_val = "3";	/* 0.3dB step */
								default_gain = "10";	/* 1dB */
								min_hdr_ratio = "1";
								max_hdr_ratio = "1";
								min_framerate = "2000000"; /* 2.0 fps */
								max_framerate = "60000000"; /* 60.0 fps */
								step_framerate = "1";
								default_framerate = "30000000"; /* 60.0 fps */
								min_exp_time = "15"; /* us */
								max_exp_time = "33214"; /* us */
								step_exp_time = "15";
								default_exp_time = "5000"; /* us */
								embedded_metadata_height = "1";
							};
							ports {
								#address-cells = <1>;
								#size-cells = <0>;
								port@0 {
									reg = <0>;
									rbpcv3_imx415_out1: endpoint {
										port-index = <2>;
										bus-width = <4>;
										remote-endpoint = <&rbpcv3_imx415_csi_in1>;
									};
								};
							};
						};
					};
				};

				gpio@2200000 {                  //add
                                      camera-control-output-low {
                                              gpio-hog;
                                              output-low;
                                              gpios = <CAM0_RST 0>;
                                              label = "cam0-rst";
                                      };
	                       };

				gpio@6000d000 {
					camera-control-output-low {
						gpio-hog;
						output-low;
						gpios = <CAM1_PWDN 0  CAM0_PWDN 0>;
						label = "cam1-pwdn", "cam0-pwdn";
					};
				};
			};
		};
	};
};

2.2 tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi 添加到设备树

在 tegra234-p3768-0000+p3767-0000-dynamic.dts 中新增 "#include "tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi"",如下:

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.

/dts-v1/;
/plugin/;

/ {
        overlay-name = "Tegra234 p3768-0000+p3767-xxxx Dynamic Overlay";
};

/*
 * Include this file last in the device tree.  It manages run-time
 * pruning of peripherals that are not available across the various
 * SKUs of p3767.  For example PVA can be enabled in the device tree
 * and it will automatically be disabled for SKUs without PVA support.
 */
#include "tegra234-p3767-sku-handling.dtsi"
#include "tegra234-p3767-camera-p3768-imx415-C-4lane.dtsi"    //设备树新增imx415内容

问题:为什么在 tegra234-p3768-0000+p3767-0000-dynamic.dts 中添加?

我们刷机命令的配置文件为 jetson-orin-nano-devkit-nvme.conf

$ sudo ./flash.sh jetson-orin-nano-devkit-nvme internal

看下 jetson-orin-nano-devkit-nvme.conf 文件相关内容,设置了 OVERLAY_DTB_FILE 的缺省值

2.3 编译设备树

1)编译

Linux_for_Tegra/source 目录下执行:

  • 设置交叉编译工具 CROSS_COMPILE 环境变量

    $ export CROSS_COMPILE=$HOME/l4

VIP RK3588S平台IMX415摄像头驱动配置与调试实战 本文详细介绍了在RK3588S平台上配置与调试索尼IMX415摄像头驱动的实战经验。内容涵盖内核驱动编译、设备树关键配置解析、上电日志分析与常见错误排查,并提供了使用v4l2-ctl工具进行图像抓取与参数调优的完整步骤,旨在帮助开发者快速完成摄像头驱动移植与图像质量调试。 开通可读全文·339 阅读·2 点赞·2 收藏 阅读全文

相关推荐

RK3588S imx415摄像头调试

RK3588S驱动摄像头IMX415,记录调试过程

6219

Sensor曝光基础知识

通过imx415 datasheet学习sensor基础知识。

David 6240

[rk3588]MIPI摄像头之imx415调试(一)

本⽂主要介绍在Rockchip平台下Camera相关代码配置,MIPI-CSI调试的通路解析

m0_60805802的博客 4002

NVIDIA AGX Xavier平台调试IMX415驱动中关于MIPI Lane调整问题的记录

总结起来,NVIDIA AGX Xavier平台上调试IMX415驱动中关于MIPI Lane调整的问题可以通过修改驱动代码中的MIPI Lane配置参数来实现。通过不断尝试不同的配置组合,可以找到最佳的MIPI Lane调整方案。MIPI Lane是指用于传输图像数据的物理通道,通过调整MIPI Lane的配置,可以影响图像传输的带宽和稳定性。需要注意的是,MIPI Lane的配置需要符合IMX415的规格要求。在进行MIPI Lane调整时,需要确保所选的Lane数量和速率是IMX415支持的范围内。

CyberLynxX的博客 513

基于高通MSM8953平台的android系统 IMX415 Camera摄像头传感器驱动开发

{0x300E, 0x00}, // HDR模式关闭。{0x3030, 0x00}, // 输出宽度低字节。{0x3031, 0x0A}, // 输出宽度高字节。{0x3032, 0x00}, // 输出高度低字节。{0x3033, 0x0A}, // 输出高度高字节。{0x300C, 0x3B}, // 像素时钟分频。{0x300D, 0x29}, // 系统时钟分频。{0x3018, 0x00}, // 数据格式。{0x3002, 0x00}, // 主模式。添加 IMX415 支持的分辨率和帧率。

zhusl6688的博客 453

IMX415驱动开发全解析

本文详细讲解在NVIDIA Jetson Orin Nano平台上开发索尼IMX415 800万像素图像传感器的完整驱动流程,涵盖设备树配置、内核驱动编写、MIPI时序协调与ISP调度等关键技术环节,实现4K@60fps高清图像采集。

rice5的博客 3111

imx415感光芯片的数据手册

imx415感光芯片的数据手册

IMIX415.rar

IMX415原理图与PCB,原理图为PDF格式,PCB为ALLRGRO格式,打开可以直接编辑,快速开发。

IMX415-AAQR-C-Datasheet-E19504(1)(1).pdf

IMX415-AAQR-C_Datasheet_E19504(1)(1).pdf

R 分析裂区试验设计

裂区试验有主区部分和副区部分, 因而有主区部分误差(误差 a,简记为Ea )和副区部分误差(误差b,简记为Eb) 分别用于测验主区处理以及副区处理和主、副互作的显著性。对同一个二因素试验资料作自由度和平方和的分解,则可发现随机区组的误差项自由度和平方和分别为DFe、SSe,而裂区设计有两个误差项,其自由度和平方和分别为DFEa,DFEb, SSEa, SSEb。而区组,处理效应等各个变异项目的自由

samhuairen的专栏 8938

线性自抗扰控制LADRC(一)---基础知识

LADRC(Linear Active Disturbance Rejection Control)是ADRC的线性化版本,通过简化非线性模块(如ESO和反馈律)降低计算复杂度,适用于实时控制系统(如电机驱动)。

ApexYuan 2084

SD - WAN:企业出海的网络加速器

例如,一家中国的跨境电商企业,在欧美市场的促销活动期间,借助 SD - WAN 技术,即使面对海量订单数据的交互,也能确保欧美客户在浏览商品、下单支付时感受到近乎本地网络的流畅体验,大大提升了客户满意度,稳住了销售增速。企业无需在海外本地部署大量冗余服务器,只需依托云台,借助 SD - WAN 快速稳定的网络连接,即可轻松实现业务拓展,进一步精简运营架构,提升整体效能。在未来,随着技术的不断演进和企业出海需求的持续增长,SD - WAN 将持续赋能,助力更多企业在全球市场扬帆远航,书写辉煌篇章。

idcicp_com的博客 448

XGBoost与Embedding混合建模实战解析

在机器学习领域,特征工程与模型融合是提升预测性能的关键技术。Embedding技术通过将高维稀疏特征(如文本、ID类数据)转化为低维稠密向量,有效捕获语义关联;而XGBoost作为强大的集成学习算法,擅长处理结构化特征并进行自动特征组合。两者结合的混合架构(如Semantic Boosted Trees)在金融风控和推荐系统等场景中展现出显著优势,尤其在处理用户行为序列、商品ID等复杂特征时,相比传统方法能获得更好的模型效果。本文通过电商推荐和金融反欺诈等案例,详解如何实现Embedding+XGBoost

weixin_28718641的博客 338

Python+OpenCV实现游戏自动刷怪脚本(附完整代码)

本文详细介绍了如何使用Python和OpenCV开发游戏自动刷怪脚本,涵盖环境搭建、图像识别、行为决策引擎及反检测优化等关键技术。通过完整的代码示例,帮助开发者实现从简单脚本到智能自动化系统的升级,提升游戏效率。

weixin_29032489的博客 529

数据获取竟如此简单——全球SRTM 90m DEM V4.1数据

SRTM(Shuttle Radar Topography Mission)是由NASA联合国际合作伙伴开展的雷达地形测绘项目,通过航天飞机搭载的合成孔径雷达系统,于2000年通过发射并接收地表反射的雷达信号,获取全球三维地形数据,这一任务填补了高精度全球地形数据的空白。而本文通过十余行的python代码,就更简单、方便地获取这些数据。

m0_38065162的博客 1404

STM32F407VET6与CH395Q串口通信实战:从零搭建以太网客户端(附完整代码)

本文详细介绍了基于STM32F407VET6微控制器与南京沁恒微CH395Q以太网芯片,通过串口通信从零搭建TCP客户端应用的完整实战过程。内容涵盖硬件连接、驱动层设计、基于FreeRTOS的任务实现以及核心调试技巧,并提供了完整的代码示例,帮助嵌入式开发者快速实现设备联网功能。

weixin_29179311的博客 420

【AI编程干货】Vibe Coding 技巧(适用于AI编程IDE)

用 AI 写代码这件事门槛低,谁都能对着对话框输入几句话让它生成代码,但生成的东西能不能用、出了问题能不能兜住,这中间的差距比想象中大得多。 我从去年开始把 AI 编码工具作为主力开发手段,中间经历过项目失控、代码雪崩、反复返工,慢慢摸索出一套相对稳定的工作方式。这篇把核心的五个习惯拆开聊聊,都是实际项目里验证过的。

blues_C的博客 632

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

蓝牙模块HM-10手册

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

SAP B1中文培訓教材_SDK

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

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

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

上一篇: Jetson Orin Nano - EC20 4G模组驱动移植
下一篇: Linux驱动编程 - gpio、gpiod函数
hinewcc
博客等级 码龄11年 739粉丝 97原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值