使用pdb调试openstack (How to debug openstack using pdb )

openstack断点pdb调试 1、以neutron的ovn代码为例,说明使用方法。代码文件是/usr/lib/python2.7/site-packages/ovsdbapp/backend/ovs_idl/idlutils.py,在需要打断点的位置输入import pdb;pdb.set_trace() 代码和pdb断点位置如下: 2、使用如下命令停止neutron-server的服务: systemctl stop n... 阅读详情

终于摸索出了一个调试openstack的简单方法,使用pdb进行单步调试,对于分析代码很有帮助。注意,这个方法只适用于用devstack安装的openstack。

调试主要是使用了一个脚本,这个脚本不记得是从哪下载的了,是用来重启使用devstack安装的openstack的各个服务的,后来,我又结合devstack的stack.sh和unstack.sh的脚本,向里面添加了一点内容,添加的功能主要是杀死前一个screen,即始终保持只有一个名为stack的screen,还添加了重启nova-conductor服务的功能。

脚本下载地址

下载之后,加上可执行权限,然后把它放在/opt/stack/devstack/目录下。


调试步骤:

1.  修改代码

在需要开始调试的地方加上这两句代码:

import pdb

pdb.set_trace()


2.  使用上面的脚本重启各个服务

stack@ubuntu:~/devstack$ ./restart_stack.sh


3.  进入screen,进行调试

stack@ubuntu:~/devstack$ screen -x stack


so easy!


需要注意的是:

1. 在第2步,如果某个服务一直在waiting,说明这个服务用到了在第1步修改的代码,那么这个时候,就要使用Ctrl+Z,把当前的进行切换到后台,然后进入到screen中,找到该服务对应的窗口,可以进行调试,如果不需要在服务启动时就进行调试的话,按‘c’,让它继续执行。之后Ctrl+a  d,退出screen,用fg把./restart_stack.sh的后台进程调出来,继续执行。

2. 在第3步,如果报类似这样“Cannot open your terminal '/dev/pts/21' - please check.”的错的话,就先输入script /dev/null,然后再进screen.

3. 脚本中的第一句,是用来重启网络的,需要输入root密码,如果不需要重启网络,就注释掉吧。


附脚本:

#!/usr/bin/env bash

# restart the interfaces
sudo /etc/init.d/networking restart

# close previrous screen
SCREEN=$(which screen)
if [[ -n "$SCREEN" ]]; then
    SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
    if [[ -n "$SESSION" ]]; then
	echo "close session: $SESSION"
	echo ""
        screen -X -S $SESSION quit
    fi
fi

TOP_DIR=$(cd $(dirname "$0") && pwd)

# create a new named screen to run processes in
screen -d -m -S stack -t stack -s /bin/bash
sleep 1
# set a reasonable statusbar
if [ -z "$SCREEN_HARDSTATUS" ]; then
    SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
fi
screen -r stack -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}

# Specify which services to launch.  These generally correspond to
# screen tabs. If you like to add other services that are not enabled
# by default you can append them in your ENABLED_SERVICES variable in
# your localrc. For example for swift you can just add this in your
# localrc to add it with the other services:
# ENABLED_SERVICES="$ENABLED_SERVICES,swift"
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,n-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit

# is_service_enabled() checks if the service(s) specified as arguments are
# enabled by the user in **ENABLED_SERVICES**.
#
# If there are multiple services specified as arguments the test performs a
# boolean OR or if any of the services specified on the command line
# return true.
#
# There is a special cases for some 'catch-all' services::
#   **nova** returns true if any service enabled start with **n-**
#   **glance** returns true if any service enabled start with **g-**
#   **quantum** returns true if any service enabled start with **q-**
function is_service_enabled() {
    services=$@
    for service in ${services}; do
        [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
        [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
        [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
        [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
    done
    return 1
}

DEST=${DEST:-/opt/stack}

# Set the destination directories for openstack projects
NOVA_DIR=$DEST/nova
HORIZON_DIR=$DEST/horizon
GLANCE_DIR=$DEST/glance
GLANCECLIENT_DIR=$DEST/python-glanceclient
KEYSTONE_DIR=$DEST/keystone
NOVACLIENT_DIR=$DEST/python-novaclient
KEYSTONECLIENT_DIR=$DEST/python-keystoneclient
OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
NOVNC_DIR=$DEST/noVNC
SWIFT_DIR=$DEST/swift
SWIFT3_DIR=$DEST/swift3
QUANTUM_DIR=$DEST/quantum
QUANTUM_CLIENT_DIR=$DEST/python-quantumclient
MELANGE_DIR=$DEST/melange
MELANGECLIENT_DIR=$DEST/python-melangeclient

# By default the location of swift drives and objects is located inside
# the swift source directory. SWIFT_DATA_DIR variable allow you to redefine
# this.
SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DEST}/data/swift}

# We are going to have the configuration files inside the source
# directory, change SWIFT_CONFIG_DIR if you want to adjust that.
SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift}

# devstack will create a loop-back disk formatted as XFS to store the
# swift data. By default the disk size is 1 gigabyte. The variable
# SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change
# that.
SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}

# The ring uses a configurable number of bits from a path’s MD5 hash as
# a partition index that designates a device. The number of bits kept
# from the hash is known as the partition power, and 2 to the partition
# power indicates the partition count. Partitioning the full MD5 hash
# ring allows other parts of the cluster to work in batches of items at
# once which ends up either more efficient or at least less complex than
# working with each item separately or the entire cluster all at once.
# By default we define 9 for the partition count (which mean 512).
SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}

# This variable allows you to configure how many replicas you want to be
# configured for your Swift cluster.  By default the three replicas would need a
# bit of IO and Memory on a VM you may want to lower that to 1 if you want to do
# only some quick testing.
SWIFT_REPLICAS=${SWIFT_REPLICAS:-3}

if is_service_enabled swift; then
    # If we are using swift, we can default the s3 port to swift instead
    # of nova-objectstore
    S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080}
fi

# Set default port for nova-objectstore
S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333}

# Set the tenant for service accounts in Keystone
SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}

HOST_IP_IFACE=${HOST_IP_IFACE:-eth0}
# Use the eth0 IP unless an explicit is set by ``HOST_IP`` environment variable
if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
    HOST_IP=`LC_ALL=C /sbin/ifconfig ${HOST_IP_IFACE} | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
    if [ "$HOST_IP" = "" ]; then
        echo "Could not determine host ip address."
        echo "Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted to eth0"
        exit 1
    fi
fi

SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}

# Glance connection info.  Note the port must be specified.
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}

# Set Keystone interface configuration
KEYSTONE_API_PORT=${KEYSTONE_API_PORT:-5000}
KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST}
KEYSTONE_AUTH_PORT=${KEYSTONE_AUTH_PORT:-35357}
KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-http}
KEYSTONE_SERVICE_HOST=${KEYSTONE_SERVICE_HOST:-$SERVICE_HOST}
KEYSTONE_SERVICE_PORT=${KEYSTONE_SERVICE_PORT:-5000}
KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-http}

# Our screenrc file builder
function screen_rc {
    SCREENRC=$TOP_DIR/stack-screenrc
    if [[ ! -e $SCREENRC ]]; then
        # Name the screen session
        echo "sessionname stack" > $SCREENRC
        # Set a reasonable statusbar
        echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC
        echo "screen -t stack bash" >> $SCREENRC
    fi
    # If this service doesn't already exist in the screenrc file
    if ! grep $1 $SCREENRC 2>&1 > /dev/null; then
        NL=`echo -ne '\015'`
        echo "screen -t $1 bash" >> $SCREENRC
        echo "stuff \"$2$NL\"" >> $SCREENRC
    fi
}

# Our screen helper to launch a service in a hidden named screen
function screen_it {
    NL=`echo -ne '\015'`
    if is_service_enabled $1; then
        echo Starting $1 ... 
        # Append the service to the screen rc file
        screen_rc "$1" "$2"

        screen -S stack -X screen -t $1
        # sleep to allow bash to be ready to be send the command - we are
        # creating a new window in screen and then sends characters, so if
        # bash isn't running by the time we send the command, nothing happens
        sleep 1.5

        if [[ -n ${SCREEN_LOGDIR} ]]; then
            screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
            screen -S stack -p $1 -X log on
            ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
        fi
        screen -S stack -p $1 -X stuff "$2$NL"
    fi
}

GLANCE_CONF_DIR=/etc/glance

# launch the glance registry service
if is_service_enabled g-reg; then
    screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf"
fi

# launch the glance api and wait for it to answer before continuing
if is_service_enabled g-api; then
    screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
    echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
      echo "g-api did not start"
      exit 1
    fi
fi

if is_service_enabled key; then
    
    KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone}
    KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf
    KEYSTONE_CATALOG=$KEYSTONE_CONF_DIR/default_catalog.templates

    # Set up logging
    LOGGING_ROOT="devel"
    if [ "$SYSLOG" != "False" ]; then
        LOGGING_ROOT="$LOGGING_ROOT,production"
    fi
    KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_CONF_DIR/logging.conf"

    # launch keystone and wait for it to answer before continuing
    screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug"
    echo "Waiting for keystone to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -O- $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/ 2>&1 | grep -q '200 OK'; do sleep 1; done"; then
      echo "keystone did not start"
      exit 1
    fi

fi

# launch the nova-api and wait for it to answer before continuing
if is_service_enabled n-api; then
    screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
    echo "Waiting for nova-api to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
      echo "nova-api did not start"
      exit 1
    fi
fi

# Launching nova-compute should be as simple as running ``nova-compute`` but
# have to do a little more than that in our script.  Since we add the group
# ``libvirtd`` to our user in this script, when nova-compute is run it is
# within the context of our original shell (so our groups won't be updated).
# Use 'sg' to execute nova-compute as a member of the libvirtd group.
# We don't check for is_service_enable as screen_it does it for us
screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute"
screen_it n-crt "cd $NOVA_DIR && $NOVA_DIR/bin/nova-cert"
screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume"
screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
screen_it n-cond "cd $NOVA_DIR && $NOVA_DIR/bin/nova-conductor"
screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ."
screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log"
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"

# Starting the nova-objectstore only if swift service is not enabled.
# Swift will act as s3 objectstore.
is_service_enabled swift || \
    screen_it n-obj "cd $NOVA_DIR && $NOVA_DIR/bin/nova-objectstore"



OpenStack源码调试之路(0)——pycharm远程调试OpenStack 要阅读一个源码,最好的方法是调试代码,一步步跟踪,会使你对整个过程的理解更加透彻,对于OpenStack也是如此,虽然看过很多分析源码的书,但总是觉得对不上号,加上有需求,所以觉得自己对源码进行一番调试。最开始试过python的pdb调试,虽然大神都说怎么怎么好,但终归是控制台的操作,一点都不直观,最后找到使用pycharm远程调试的方法,觉得非常好用,windows下可视化界面,变量查看,追踪回... 阅读详情

相关推荐

Pycharm 下远程调试 Neutron 简介

实验背景及环境介绍 众所周知要深入学习一款开源软件就去阅读它的源码吧,但如果只是阅读冷冰冰的代码,往往是一头雾水,你肯定希望知道代码运行起来的上下文、变量值的变化,那么你需要调试。对于 Openstack 来说,大多代码都是开源 Python 编写的,这对于学习来说成本低很多,因为你可以随时修改它的代码,重启下进程你的代码就开始运行了。即使这样,对于调试 Openstack 这样大型的软件还

海风林影 2198

用PDB库调试Python程序

如果使用过微软技术的朋友应该体会过微软的Visual Studio系列IDE给debug程序带来的方便,换了个工作就没有Visual Studio了,对于我这种从未在非GUI环境下调试过程序的人来说实在有点不爽,今天花了点时间看了一下Python自带的pdb库,发现用pdb来调试程序还是很方便的,当然了,什么远程调试,多线程之类,pdb是搞不定的。用pdb调试有多种方式可选:1.

byrsongQQ的专栏 1142

自动驾驶传感器选型实战:摄像头、激光雷达与毫米波雷达融合策略

自动驾驶感知系统的核心在于多传感器协同,而非单一技术优劣。摄像头擅长语义识别但受光照和天气制约;激光雷达提供高精度测距却面临成本、温漂与多径干扰等物理瓶颈;毫米波雷达则以全天候鲁棒性与精准测速成为安全底线的守门人。三者融合不是简单叠加,而是基于场景约束(如暴雨、强光、高速跟车)、成本边界(BOM控制)与时间窗口(量产节奏)的工程权衡。真实量产方案中,‘纯视觉’实为视觉主责+毫米波兜底,‘激光雷达上车’本质是用硬件真值加速算法迭代,而传统车企更倾向以毫米波为仲裁者协调冲突。理解这些底层原理,才能在传感器选型、

weixin_32495691的博客 276

openstack调试

openstack调试   对于开源的openstack而言,调试显然非常重要,在调试的过程中,我们可以跟踪代码的执行过程,对于我们理解openstack的结构和框架有十分重要的意义。在之前的教程中提到的使用devstack工具在虚拟机中安装部署openstack,通常虚拟机运行会有点卡,为了不让虚拟机那么卡,我们抛弃了较大的python IDE(pycharm和eclipse等)。使用的是最为...

weixin_30362801的博客 239

[软考]系统架构设计师 备考经验分享(一) - 备考计划篇

前言 上周末刚刚结束了软考架构师的考试,自我感觉考的还可以,大概率是过了。 两次参加软考,一次中级嵌入式,一次高级架构师,都是备考不到两个月时间,尤其是架构师这次考试内容和本职工作有不小的差别,并且需要同时备考三个科目,在高强度地备考中感觉是摸索出到了一点软考的技巧与经验。 打算趁还记得,赶紧写几篇文章做下梳理总结,算是给将来自己考系分、高项或者其他考试做个记录,也希望能够帮到正在备考的大家。 先把第一步,个人的备考计划分享给大家。 自身情况分析 首先,请大家一定先明确三个问题,这三个问题会直接影响到你的

_ 6404

别再死磕DH参数了!用MATLAB Robotics Toolbox + SOLIDWORKS搞定六轴机械臂仿真(附避坑指南)

本文详细介绍了如何利用MATLAB Robotics Toolbox和SOLIDWORKS进行六轴机械臂仿真,避免常见的DH参数错误和模型导出问题。通过实战指南和避坑技巧,帮助工程师实现从三维建模到运动学仿真的无缝衔接,提升仿真效率和准确性。

weixin_27066963的博客 394

用pdb调试OpenStack

点击打开链接 [plain] view plaincopy ADMIN_PASSWORD=password   MYSQL_PASSWORD=stackdb   RABBIT_PASSWORD=stackqueue   SERVICE_PASSWORD=$ADMIN_PASSWORD   #enable_service ral

luzheqi的专栏 1751

爆肝整理:微信公众号文章HTML编写完整规范,运营必备手册

微信公众号文章排版总是出错?📱 这份完整的HTML编写规范文档帮你彻底解决!文档包含所有支持的标签、CSS属性、实用代码模板和注意事项 📋,让你快速掌握微信文章的HTML编写技巧,告别第三方编辑器依赖 ✅

XiaoqiangClub的博客 2306

调试openstack源码的方法

1,首先在源码文件里打个断点(import pdb;pdb.set_trace()) 2,停掉对应的服务(systemctl stop xxx) 3,手动启动该服务 4,重开一个窗口,执行调用包含断点源码文件的服务(比如nova-api,nova-compute) 5,原窗口将会在断点处停止

pengdake300的博客 727

用 Custom Entity 打造 RAP Value Help:从能跑到好用的深度踩坑笔记

本文介绍了在RAP项目中实现Value Help(Fiori输入帮助)的完整流程。通过Custom Entity方式,开发者可以灵活构建不依赖数据库实体的值帮助功能,但需手动实现CDS原本提供的过滤、排序、分页等能力。文章以一个典型场景为例,详细说明了如何为Partner维护界面的City字段创建可搜索的值帮助,包括创建查询实现类、绑定CDS Custom Entity、服务发布等关键步骤,并特别指出了处理排序分页请求等常见问题。最后强调在ABAP Cloud环境下需要自行实现查询能力,而非依赖传统工具类。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 137

概念解析 | 事件相机的原理 (含仿真代码)

在我们熟悉的世界里,传统相机就像一个勤勉的绘画师,每隔固定的时间就为我们勾勒出一幅完整的画面。但是,大自然中有太多瞬息万变的精彩场景,这种"定时绘画"的方式往往难以捕捉。于是,一种全新的"观察者"应运而生 -事件相机(Event Camera)。事件相机,就像是一群极其敏感的"像素哨兵",它们不再按部就班地等待指令,而是主动感知周围的变化,只有在光线强度发生显著变化时才会发出信号。这种革命性的设计,让事件相机拥有了传统相机难以企及的优势:超高的时间分辨率、极低的延迟、宽广的动态范围,以及出色的能效比。

NLOS的博客 1422

openstack调试方法总结

因为前几天Komodo突然一下在使用中没法代码自动补全,没法进行代码自动提示了,自己折腾了(大概十个小时,卸载重装了很多次)很久也没法让它对python代码进行自动提示,很无语,于是彻底放弃,改用Eclipse+pyDev平台。虽然浪费了时间,但是已经对Eclipse有些熟练了,还是有所收获哦。   Python的安装比较简单,因此python的安装就不说了,Eclipse的基础环境,JRE

jincm的专栏 5972

2026国内Claude Code保姆级教程:安装、避坑、防串台全优化

安装 Claude Code CLI + 切换 npm 国内镜像优先配置固定关闭:自动联网、自动项目扫描VSCode 内置终端直接用,不装多余插件会话隔离+指令约束,彻底解决 Rust、小程序 跨语言串台。

lpfasd123的博客 2544

用pdb调试OpenStack Havana

作为个人学习笔记分享,有任何问题欢迎交流! Note:若是想要用pdb调试OpenStack,必须通过Devstack安装它。 Devstack安装Havana过程 1.使用一般用户(非root用户),从github上获取devstack代码 git clonehttps://github.com/openstack-dev/devstack.g...

weixin_30872867的博客 201

【图像去噪】论文复现:CLIP用于图像去噪提升泛化性!CLIPDenoising的Pytorch源码复现,跑通CLIPDenoising全流程,图文结合,网络结构梳理和拆解,对应源码注释!

论文题目:Transfer CLIP for Generalizable Image Denoising —— 用于可泛化图像去噪的转移CLIP。【图像去噪】论文精读:Transfer CLIP for Generalizable Image Denoising(CLIPDenoising)CLIPDenoising理论部分详解见上面对应的论文精读,本文以源码为主,理论部分只是粗略回顾。启发:多看其他领域的文章,分析是否能应用在去噪领域,这是产生idea的要素之一;

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 1414

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

OpenStack之调试——Pdb调试

用pdb调试有多种方式可选: 1. 命令行启动目标程序,加上-m参数,这样调用myscript.py的话断点就是程序的执行第一行之前 python -m pdb myscript.py 2. 在Python交互环境中启用调试 >>> import pdb >>> import mymodule >>> pdb.run(‘mymodule.test()’) 3. 比较常用的,就

仇晗的专栏 1673

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

openstack代码调试

主要记录openstack代码如何进行调试的一个流程 用的是devstack搭建的openstack,搭建完毕之后,想着用pdb进行单步调试,可以加深对代码的理解 下面以nova api为例进行说明: 首先安装remote_pdb工具,LOG.debug()是加上相应的打印信息,可以在/var/log/syslog文件中查看到 在create函数中增加from remote_pdb import RemotePdb RemotePdb('127.0.0.1',4444).set_trace()

qq_33970713的博客 635

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

使用pdb调试ceilometer代码

本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。 声明: 本博客欢迎转发,但请注明出处,保留原作者信息 博客地址:孟阿龙的博客 所有内容为本人学习、研究、总结。如有雷同,实属荣幸 Newton版本以前,Ceilometer代码调试方法: ceilometer在Newton版本以前,polling-agent使用的是oslo_service模块启...

mengalong的博客 616

怎样调试OpenStack Unit Test

相信大家都知道执行OpenStack的Unit Test,非常简单,只需要执行"run_tests.sh"就可以,但是有没有想过怎么 去调试这些Unit Test脚本呢,有个方法是使用"nosetests",具体如下: 1)修改你要调试的文件,加上"pdb.set_trace()",我现在用test_scheduler.py举例 class SchedulerDriverModuleT

狂飙的蜗牛 4151

gdb 多线程调试 暂停其他线程_OpenStack断点调试方法总结

1 关于断点调试断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT 3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT 3指令,进程运行时遇到INT ...

weixin_39890431的博客 717

.net 网络调试助手源码_OpenStack断点调试方法总结

01关于断点调试断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT 3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT 3指令,进程运行时遇...

weixin_39748183的博客 219

python openstack oslo_config使用_OpenStack 断点调试方法总结(其他 Python 程序同样适用)...

1、断点调试的目的和工具断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT3指令,进程运行时遇到I...

weixin_39832829的博客 138

nova-compute 的pdb调试方法

最近live snapshot总出问题,想自己深入调试,采用了pdb。 Openstack其他组件的调试方法大同小异,这里仅以nova-compute举例。 1. 首先要停止nova-compute服务。 service nova-compute stop2. 插入断点,比方说我在driver.py 4832行插入。 import pdb; pdb.set_trace() 3.

阿Q的专栏 1347

debugging openstack with pdb

在要开始debug的地方导入pdb: class KeypairAPI(base.Base): """Sub-set of the Compute Manager API for managing key pairs.""" def __init__(self, **kwargs): super(KeypairAPI, self).__init__(...

weixin_33701564的博客 83
上一篇: policy机制中经典的python用法
下一篇: My OpenStack Weekly Reports——社区
hackerain
博客等级 码龄16年 753粉丝 220原创
评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值