配置Emacs下的Python开发环境

Emacs Python_Emacs – 一个强大的 Python 编辑器 如果你是一个 Python 开发者,并且想要提高你的编码效率和质量,不妨尝试一下 Emacs Python_Emacs 插件吧!Emacs 是一种自由、可定制的文本编辑器,它具有强大的扩展功能,可以通过插件来满足不同编程语言的需求。Python_Emacs 是 Emacs 中专门为 Python 开发者提供的插件,它提供了一系列强大的功能和工具,使得 Python 开发变得更加高效和愉快。在这个示例中,我们使用 Python_Emacs 的调试功能来逐步执行递归的阶乘函数,并查看每一步的变量值。 阅读详情

特性

在Linux论坛上总有人问Python用什么IDE比较好,然后总会有人回答说Emacs。最近开始学Python,也花了点时间研究怎么配置Emacs,发现没有想象中的那么麻烦。这篇文章大致上来自于网上的整理,完成以后的Emacs具有以下特性:

  • 自动完成同一个文件内的变量、函数
  • 自动完成python库中的名称
  • 代码重构
  • 模板展开功能
  • 在线帮助系统
  • 即时语法检测

其他特性还包括自动缩进,括号匹配,语法高亮,代码折叠等等。其中最有用的莫过于自动完成了,貌似很少有python编辑器可以做到这一点。而即时语法检测让emacs下的python代码书写变得像Eclipse一样,一旦有错误立刻就会高亮标记出来。

如何安装

首先你得在home目录下有一个.emacs配置文件,并且有一个用来放插件的文件夹(比如说~/.emacs.d/)

  1. 下载auto-completion.el到.emacs.d,并且在.emacs中添加如下几行: 
    (require ‘auto-complete)
    (global-auto-complete-mode t)
  2. 下载yasnippet到.emacs.d并且编辑.emacs:
    (require ‘yasnippet) (yas/initialize) (yas/load-directory “~/.emacs.d/snippets”)
  3. 下载python-mode.el并且放到.emacs.d中。我们会在之后的配置中用到它
  4. 设置Rope, Ropemacs

    我们需要使用最新的development版的rope和ropemacs,否则在emacs中不能找到rope-completion函数。通过如下步骤安装:

    sudo apt-get install mercurial python-setuptools
    mkdir /tmp/rope && cd /tmp/rope
    hg clone http://bitbucket.org/agr/rope
    hg clone http://bitbucket.org/agr/ropemacs
    hg clone http://bitbucket.org/agr/ropemode
    sudo easy_install rope
    ln -s ../ropemode/ropemode ropemacs/
    sudo easy_install ropemacs
  5. 到 http://pymacs.progiciels-bpi.ca/archives/ 下载 pymacs并安装
    mkdir -p ~/.emacs.d/vendor && cd ~/.emacs.d/vendor tar zxvf pinard-Pymacs-v0.25-0-g5989046.tar.gz 
    sudo easy_install . 
    
  6. 添加.emacs Pymacs的路径                                                                                                                                                                               (add-to-list 'load-path "~/.emacs.d/vendor")
    (progn (cd "~/.emacs.d/vendor")
    (normal-top-level-add-subdirs-to-load-path))
  7. 安装pyflacks以进行自动语法检查:
    sudo apt-get install pyflakes
  8. 把所有东西放到一块儿

    在你的.emacs.d中创建一个init_python.el,并且加入以下内容:

    (autoload 'python-mode "python-mode" "Python Mode." t)
    (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
    (add-to-list 'interpreter-mode-alist '("python" . python-mode))
    (require 'python-mode)
    (add-hook 'python-mode-hook
    (lambda ()
    (set-variable 'py-indent-offset 4)
    ;(set-variable 'py-smart-indentation nil)
    (set-variable 'indent-tabs-mode nil)
    (define-key py-mode-map (kbd "RET") 'newline-and-indent)
    ;(define-key py-mode-map [tab] 'yas/expand)
    ;(setq yas/after-exit-snippet-hook 'indent-according-to-mode)
    (smart-operator-mode-on)
    ))
    ;; pymacs
    (autoload 'pymacs-apply "pymacs")
    (autoload 'pymacs-call "pymacs")
    (autoload 'pymacs-eval "pymacs" nil t)
    (autoload 'pymacs-exec "pymacs" nil t)
    (autoload 'pymacs-load "pymacs" nil t)
    ;;(eval-after-load "pymacs"
    ;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY"))
    (pymacs-load "ropemacs" "rope-")
    (setq ropemacs-enable-autoimport t)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; Auto-completion
    ;;; Integrates:
    ;;; 1) Rope
    ;;; 2) Yasnippet
    ;;; all with AutoComplete.el
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun prefix-list-elements (list prefix)
    (let (value)
    (nreverse
    (dolist (element list value)
    (setq value (cons (format "%s%s" prefix element) value))))))
    (defvar ac-source-rope
    '((candidates
    . (lambda ()
    (prefix-list-elements (rope-completions) ac-target))))
    "Source for Rope")
    (defun ac-python-find ()
    "Python `ac-find-function'."
    (require 'thingatpt)
    (let ((symbol (car-safe (bounds-of-thing-at-point 'symbol))))
    (if (null symbol)
    (if (string= "." (buffer-substring (- (point) 1) (point)))
    (point)
    nil)
    symbol)))
    (defun ac-python-candidate ()
    "Python `ac-candidates-function'"
    (let (candidates)
    (dolist (source ac-sources)
    (if (symbolp source)
    (setq source (symbol-value source)))
    (let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit))
    (requires (cdr-safe (assq 'requires source)))
    cand)
    (if (or (null requires)
    (>= (length ac-target) requires))
    (setq cand
    (delq nil
    (mapcar (lambda (candidate)
    (propertize candidate 'source source))
    (funcall (cdr (assq 'candidates source)))))))
    (if (and (> ac-limit 1)
    (> (length cand) ac-limit))
    (setcdr (nthcdr (1- ac-limit) cand) nil))
    (setq candidates (append candidates cand))))
    (delete-dups candidates)))
    (add-hook 'python-mode-hook
    (lambda ()
    (auto-complete-mode 1)
    (set (make-local-variable 'ac-sources)
    (append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
    (set (make-local-variable 'ac-find-function) 'ac-python-find)
    (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate)
    (set (make-local-variable 'ac-auto-start) nil)))
    ;;Ryan's python specific tab completion
    (defun ryan-python-tab ()
    ; Try the following:
    ; 1) Do a yasnippet expansion
    ; 2) Do a Rope code completion
    ; 3) Do an indent
    (interactive)
    (if (eql (ac-start) 0)
    (indent-for-tab-command)))
    (defadvice ac-start (before advice-turn-on-auto-start activate)
    (set (make-local-variable 'ac-auto-start) t))
    (defadvice ac-cleanup (after advice-turn-off-auto-start activate)
    (set (make-local-variable 'ac-auto-start) nil))
    (define-key py-mode-map "\t" 'ryan-python-tab)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; End Auto Completion
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Auto Syntax Error Hightlight
    (when (load "flymake" t)
    (defun flymake-pyflakes-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
    'flymake-create-temp-inplace))
    (local-file (file-relative-name
    temp-file
    (file-name-directory buffer-file-name))))
    (list "pyflakes" (list local-file))))
    (add-to-list 'flymake-allowed-file-name-masks
    '("\\.py\\'" flymake-pyflakes-init)))
    (add-hook 'find-file-hook 'flymake-find-file-hook)
    (provide 'init_python)
  9. 在你的.emacs文件中添加:(load-library “init_python”)

使用说明

  1. 代码自动展开。比如说在编辑C/C++头文件的时候键入once然后按tab,则会自动展开#ifndef__FILE_H__这样的宏。这个功能是YASnippet提供的,在emacs的菜单中可以看到它的所有宏。展开以后再按tab键可以在已展开的代码之间切换位置。
  2. 自动完成代码。函数名输入到一半按tab键会调用Rope和Ropemacs的功能自动完成库文件中的函数、变量名
  3. C-c d 显示python的doc string
  4. C-c C-c 运行当前的文件
  5. C-c ! 打开python shell

事实上init_python.el做的事情是通过使用auto_complete.el中的功能,把YASnippet和Rope的功能结合到了一块儿,实现了类似TexMate的自动完成等功能。其中YASnippet可以自定义模板,很是实用。Rope的功能还在研究中。



Emacs个性化配置:打造高效Python开发环境 Emacs 是一种功能强大的文本编辑器,它在 IT 专业人员中有着悠久的历史和忠实的用户群。它不仅支持基本的文本编辑功能,还提供了丰富的扩展插件,使其成为一个强大的集成开发环境(IDE)。本章将为读者介绍 Emacs 的核心概念、基本操作和扩展生态,为接下来深入探讨如何在 Emacs 中配置和使用 Python 开发工具打下坚实的基础。我们将从了解 Emacs 的起源和发展历程开始,然后逐步过渡到介绍如何在不同操作系统上安装 Emacs。 阅读详情

相关推荐

Linux 下 Emacs 安装与配置:从终端编辑器到 Python 开发环境

在 Linux 系统管理中,文本编辑器是运维和开发的基础工具。Emacs 作为可编程的编辑器,通过 Lisp 解释器实现高度定制,在纯终端环境下也能高效工作。其核心价值在于提升配置管理、脚本编写和故障排查的效率,尤其适合服务器运维和 Python 开发场景。本文围绕 Emacs 在 Linux 上的安装、最小配置、Python 环境搭建及常见问题排查展开,帮助读者快速上手这一利器。

weixin_28840591的博客 326

linux环境下python的IDE,Linux 下配置 Python IDE——Emacs

工欲善其事,必先利其器。Python作为高级语言,因为其简介、灵活已经被越来越多的程序员所青睐。在尝试了众多IDE之后,终于找到了自己的挚爱。废话少说,下面开始说一下如何在linux下安装配置Emacs。当然Emacs 还支持很多种程序语言,例如:Ruby / Ruby on RailsCSS / LESS / SASS / SCSSHAML / Markdown / Textile / ERBC...

weixin_42299494的博客 742

Win10安全模式下修改C盘权限的完整指南(附解决开始菜单失灵方案)

本文提供了一份在Win10安全模式下修复因C盘权限误改导致开始菜单失灵的完整指南。文章深入剖析了权限体系,特别是TrustedInstaller角色的重要性,并详细讲解了通过安全模式进入系统、使用ICACLS命令或图形界面精准重置C盘关键目录权限的步骤,最终恢复系统核心功能。

weixin_29250403的博客 234

emacs python_将Emacs打造成强大的Python代码编辑工具

基本配置Emacs本身提供了python-mode,输入M-x python-mode,就可以进入python模式。相应地,会在菜单栏出现Python菜单。当然,一般来讲,如果是.py文件打开的话,也会自动进入该模式。不过,默认的python模式功能上面用起来还是有点弱,而且许多地方做的并不好,最好下载第三方的python模式。python-mode是一个开源项目,可以在https://launc...

weixin_39862794的博客 2013

长安车机破解后能干啥?分享我的UNI-K车机安装第三方应用与优化体验实录

本文详细记录了长安UNI-K车机破解后的实用玩法与深度优化指南,包括安装第三方应用、导航体验升级、影音系统改造及系统美化等。通过工具箱和升级技巧,车主可以大幅提升用车体验,解锁更多隐藏功能。

weixin_33217202的博客 404

华为HCIA-Datacom实战:200人企业园区网从规划到部署全流程解析

本文详细解析了华为HCIA-Datacom认证实战中200人企业园区网的规划与部署全流程。从需求分析、组网架构设计到设备选型、VLAN划分及安全策略实施,全面覆盖园区网建设的关键环节,特别针对部门隔离、无线覆盖和基础安全防护等典型场景提供可落地的解决方案。

f0g1h2的博客 710

【Python】探索 Elpy:Emacs 中的 Python 开发环境

对于使用 Emacs 编辑器的 Python 开发者来说,`Elpy` 是一个强大的集成开发环境(IDE),它通过整合多个 Emacs Lisp 和 Python 包,提供了一套完整的 Python 编程支持。本文将介绍 Elpy 的核心特性、安装方法以及如何快速上手。

技术无疆 1735

Open3D 进阶(32)渐进三角网(PTD)地面滤波

渐进三角网地面滤波算法(Progressive TIN Densification, PTD)是一种广泛应用于机载LiDAR点云数据处理的滤波方法,旨在从复杂场景中精确分离地面点,以生成数字高程模型(DEM)。

点云侠的博客 1534

Emacs 降魔系列之制作 Python IDE

个人的武装配置比较搓。希望大神指正下。 我们先去这里收集主人公闯关道具 —— 昊天塔 emacs for windows:http://ftp.gnu.org/gnu/emacs/windows/ 我使用的是冥界版 24.3。 释放 emacs 的灵压,将其解压 emacs 在你需要的目录下,在解压后生成的 bin 目录下,点击 addpm.exe, 会在 “C:\Users\Ad

一刀不二 5994

【2025华为OD机考真题】- 简易内存池(B卷-200分)(C版)

🔔本文收录于「最新最全华为OD机试真题(C版)」专栏,手把手带你零基础教学华为OD机试。本题集提供最优题解思路,解题步骤,代码解析,复杂度分析及最优题解源码等,支持多语言题解,助你轻松拿捏OD机考,一举上岸!安利大家关注&&收藏&&订阅!题库正在疯狂收录中,up!up!up!! 🚫提醒:拒绝一切代考/替考,违法必究!专栏所写题库均精心搜集于互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验所撰,欢迎订阅。    💗订阅福利:一次订阅,可永久免费阅读,提供在线答疑解惑,后续题库更新皆可阅

**My Coding Family** 961

背靠背VSC直流母线电压控制与同步发电机并网发散问题:原理、分析与解决方案

背靠背VSC直流母线电压控制与同步发电机并网发散问题分析 摘要: 本文研究了背靠背VSC系统在整流侧由理想三相电源切换为同步发电机时出现的直流母线电压振荡和发散问题。通过理论分析发现,锁相环同步失稳、等效阻抗失配和直流母线电容参数失配是导致系统失稳的关键因素。当整流侧接入同步发电机后,系统形成正反馈振荡回路,同时等效电感增大导致电流环响应速度降低,直流侧电容容量不足无法吸收发电机功率波动。文章提出了从跟网型控制到构网型VSG控制的完整升级方案,包含详细的MATLAB/Simulink建模和控制算法实现,并通

huanghm88的专栏 121

配置emacs的python开发环境

本文将介绍,在Emacs中,通过各种扩展,打造强大的Python IDE环境,包括Snippet工具,智能提示,自动补全,重构工具,调试以及GAE的调试,等等。以下各工具的安装前提是你对Emacs的配置文件有一定的了解,所有相关的el文件都必须放在load_path能够加载的地方

qinxiuchen的专栏 1840

Juniper SRX PPPoE配置

set interfaces pp0 unit 1 ppp-options chap default-chap-secret 拨号用户名密码。set interfaces pp0 unit 0 ppp-options chap default-chap-secret 拨号密码。set interfaces pp0 unit 0 ppp-options chap local-name 拨号用户名。6号口接运营商进行拨号。

Jian Sun_的博客 750

配置emacs python 开发环境

安装版本emacs 24及以上配置emacs包管理的源; start package.el with emacs

风云的专栏 6833

如何使用 ABAP 代码调度一个 ABAP 程序,让其以后台作业的方式运行

笔者之前的教程,介绍了如何使用 SM36 一系列事务码,将一个 ABAP 程序,调度成以后台作业方式运行的详细步骤。 38. 如何让 ABAP 报表在后台作业的模式下运行 大家如果照着上述文章的步骤走一遍,会发现这些手动执行的步骤还是有些繁琐的。 有没有可能让这一切都自动化起来,即通过 ABAP 代码去完成呢?当然可以。

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

SAP B1中文培訓教材_SDK

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

emacs python开发环境_配置emacs作为python的集成开发环境,支持代码自动补全

作为一个挨踢老兵,最近终于有点闲暇时间,突然想重温一下emacs,玩玩python和人工智能。实话说,听说归听说,自己真的开始配置emacs作为python的集成开发环境,还真是费了不少周折,通过姑娘找到的帮助基本上都没通,倒是最终通过google收到的文章靠谱。一、准备工作1、下载python我下载的是2.7.13,貌似3以上的现在好多工具支持还不到位。2、下载emacs二、emacs基础刚接触...

weixin_39870700的博客 602

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

[Emacs系列]:配置Python开发环境指南(一)

emcas配置python自动补全

Chen某人的成长记录 1845

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

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

emacs python开发环境_配置Emacs下的Python开发环境

特性在Linux论坛上总有人问Python用什么IDE比较好,然后总会有人回答说Emacs。最近开始学Python,也花了点时间研究怎么配置Emacs,发现没有想象中的那么麻烦。这篇文章大致上来自于LeiChen博客文章的翻译,完成以后的Emacs具有以下特性:自动完成同一个文件内的变量、函数自动完成python库中的名称代码重构模板展开功能在线帮助系统即时语法检测其他特性还包括自动缩进,括号匹配...

weixin_39561577的博客 427

emacs python开发环境_Windows上配置Emacs来开发Python及用Python扩展Emacs

Windows下配置Emacs来开发Python去年在网上偶然的一个机会知道了Emacs的存在,在周围前辈们都在夸赞Sublime好用的时候,喜欢跟大众唱反调的我,突然觉得如果能用Emacs来编代码,也许是个很牛的技能。但是在看了一次Tutorial后,就因为复杂的快捷键和不同于一般编辑器的操作方式放弃了这个想法。今年开始工作以后,公司还没有给我发配项目,让我有时间学了些Python入门。在寻找合...

weixin_39575410的博客 673

emacs python开发环境_Emacs之Python编程环境配置 - elpy

由于之前一直使用Emacs+Jedi来进行Python的编程环境,最近又尝试了Emacs+Elpy的方式。接下来直接开始吧,少些废话。首先系统当中要安装pip等工具,方便安装python的一些工具包(在CentOS6.5 64位系统上进行的操作),wgethttps://bootstrap.pypa.io/ez_setup.py-O-|pythoneasy_installpipyum...

weixin_39905725的博客 679

Elpy:在Emacs中打造专业Python开发环境的终极指南

你是否正在寻找一个强大的Python开发环境,但又不想离开你钟爱的Emacs编辑器?Elpy就是你的完美解决方案!作为Emacs中最完整的Python集成开发环境,Elpy将现代IDE的所有强大功能带入了这个经典的文本编辑器。无论你是Python新手还是经验丰富的开发者,Elpy都能显著提升你的编码效率和体验。💪 ## 为什么选择Elpy作为你的Python开发环境? Elpy不仅仅是一个简

gitblog_00678的博客 400

在fedora16中,设置emacs成为python开发环境

1.python-mode python-mode 是emacs自带的由python社区开发的插件,有一些非常有用的快捷键: python-shift-left, C-c C- 向左边缩进 python-shift-right, C-c C- 向右边缩进 python-switch-to-python, C-c C-z 打开(或者切换到)python-shell

FlyDirk的专栏 2625

emacs配置python环境

1 安装完python后,首先需要确认pathon是否在PATH下,即在cmd命令符中键入”python“,若得到python的版本信息,则表示pathon已在PATH下,否则需要设置环境变量,方法与设置java环境变量雷同,在此不作多余叙述。 2 从https://launchpad.net/python-mode下载到的Python-mode的最新版本。 3 将Python-mode解压后的

Frances_S的漫漫SE路 947

windows+vagrant+python+emacs开发环境配置

背景说明 公司的电脑一般都是windows系统的。但是windows系统如果配置开发环境,在安装一些依赖的时候经常会抓狂。Vagrant是一个基于Ruby的工具,用于创建和部署虚拟机。通过vagrant工具在windows系统上拉起一台linux系统的虚拟机,在上面安装emacs,然后通过 mobaxterm 工具的X server 功能,在windows上远程打开虚拟机中的emacs GUI界...

weixin_30701575的博客 140

Emacs 下安装 python-mode.el

1. 确保你的python在PATH下,即,在cmd中输入python,能够进入python shell,如果不能,请配置环境变量,将python目录加入PATH 2. 下载python-mode: https://launchpad.net/python-mode 解压后,运行python setup.py install 安装,如果不能安装,请先安装setuptools,在http://py

KingKazma 的专栏 1744
上一篇: linux关闭触摸板方法
下一篇: 2013 年关于 Linux 的 5 个预测
horst_hu
博客等级 码龄15年 38粉丝 34原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值