| 1 | Nevow XML Templates |
|---|---|
| 2 | =================== |
| 3 | |
| 4 | Stan syntax is cool, but eventually you are going to want to integrate your |
| 5 | Python code with a template designed by an HTML monkey. Nevow accomplishes this |
| 6 | by providing an xmlfile loader which uses the built-in Python SAX libraries to |
| 7 | generate a tree of stan behind the scenes. The general rule is anything that is |
| 8 | possible in stan should be possible in a pure XML template; of course, the XML |
| 9 | syntax is generally going to be much more verbose. |
| 10 | |
| 11 | * `loaders.xmlfile`_ |
| 12 | * `Nevow's xmlns declaration`_ |
| 13 | * `Nevow's Tag Attribute Language`_ |
| 14 | * `nevow:render`_ |
| 15 | * `Built-in renderers`_ |
| 16 | * `nevow:data`_ |
| 17 | * `nevow:pattern`_ |
| 18 | * `nevow:slot`_ |
| 19 | * `nevow:attr`_ |
| 20 | * `nevow:invisible`_ |
| 21 | * `xmlstr, htmlfile, and htmlstr`_ |
| 22 | |
| 23 | loaders.xmlfile |
| 24 | --------------- |
| 25 | |
| 26 | Wherever you have seen a loaders.stan being created in any of the example code, |
| 27 | a loaders.xmlfile can be substituted instead. At the most basic, xmlfile merely |
| 28 | requires the name of an xml template:: |
| 29 | |
| 30 | class HelloXML(rend.Page): |
| 31 | docFactory = loaders.xmlfile('hello.xml') |
| 32 | |
| 33 | Placing the following xml in the hello.xml file will cause HelloXML to display a |
| 34 | static page when it is rendered:: |
| 35 | |
| 36 | <html>Hello, world!</html> |
| 37 | |
| 38 | The following additional keyword arguments may be given to xmlfile to configure |
| 39 | it: |
| 40 | |
| 41 | templateDirectory |
| 42 | The path to the directory which contains the template file. Defaults to ''. |
| 43 | |
| 44 | ignoreDocType |
| 45 | If True, discard any DOCTYPE declaration when building the DOM from this |
| 46 | template. When false, preserve the DOCTYPE, causing it to show up in the final |
| 47 | output. Useful for when you are inserting an XML fragment into a larger page |
| 48 | and do not wish to generate invalid XML as output. Defaults to False. |
| 49 | |
| 50 | ignoreComment |
| 51 | If True, discard XML comments, causing them to disappear from the output. If |
| 52 | False, preserve comments and render them in the final output unchanged. |
| 53 | Defaults to False. |
| 54 | |
| 55 | pattern |
| 56 | If present, the given pattern name will be looked up and used as the root of |
| 57 | the template. If not present, the entire document will be used as the |
| 58 | template. Useful for embedding fragments of an XML document in a larger page. |
| 59 | Defaults to None. |
| 60 | |
| 61 | Nevow's xmlns declaration |
| 62 | ------------------------- |
| 63 | |
| 64 | In order for Nevow to notice and process any XML directives in the template |
| 65 | file, you must declare the Nevow xmlns at the top of your XML document. Nevow's |
| 66 | xmlns is:: |
| 67 | |
| 68 | http://nevow.com/ns/nevow/0.1 |
| 69 | |
| 70 | The syntax for declaring that your xml document uses this namespace is:: |
| 71 | |
| 72 | <html xmlns:nevow="http://nevow.com/ns/nevow/0.1"></html> |
| 73 | |
| 74 | You may replace the text "nevow" in the above example with any name you choose. |
| 75 | For example, many people use "n" because it is shorter to type. If you do so, be |
| 76 | sure to replace all occurrences of the nevow namespace in the examples with the |
| 77 | namespace name you choose. |
| 78 | |
| 79 | Nevow's Tag Attribute Language |
| 80 | ------------------------------ |
| 81 | |
| 82 | The markup you will add to your XHTML file in order to invoke Nevow code |
| 83 | consists mostly of namespaced tag attributes. This approach was influenced |
| 84 | heavily by the Zope Page Templates (ZPT) Tag Attribute Language (TAL). However, |
| 85 | I felt that TAL did not go far enough in removing control flow and branching |
| 86 | possibilities from the XML template. Nevow's main philosophy is that it should |
| 87 | be as easy as possible to move from the XML document into Python code, and that |
| 88 | the Python code should have ultimate control over manipulating the structure of |
| 89 | the XML template. |
| 90 | |
| 91 | The key is that it is easy to expose Python methods that you write to your XML |
| 92 | template, and it is easy for the XML templates to mark nodes which it wishes the |
| 93 | Python method to manipulate. In this way, if either the Python implementation |
| 94 | changes or the location or content of the marked nodes change in the XML |
| 95 | template, the other side will be isolated from these changes. |
| 96 | |
| 97 | Nevow's XML templating has two attributes which invoke Python code: |
| 98 | |
| 99 | * nevow:render -- Invokes a Python method and replaces the template node with the result |
| 100 | * nevow:data -- Invokes a Python method and sets the data special for the node to the result |
| 101 | |
| 102 | It has one attribute which marks nodes as manipulatable by Python code: |
| 103 | |
| 104 | * nevow:pattern -- Gives a node a name so that Python code may clone and mutate copies of this node |
| 105 | |
| 106 | It also has two namespaced tags: |
| 107 | |
| 108 | * nevow:slot -- Works in the same way as the slot attribute |
| 109 | * nevow:attr -- Indicates that an attribute of the parent tag should be manipulated by Python code in some way |
| 110 | |
| 111 | nevow:render |
| 112 | ------------ |
| 113 | |
| 114 | When the nevow:render attribute is encountered, the xmlfile loader sets the |
| 115 | render special to a directive constructed with the attribute value. When the |
| 116 | template is rendered, this means that the appropriate render_* method will be |
| 117 | looked up on the IRendererFactory (generally the Page instance):: |
| 118 | |
| 119 | <html><div nevow:render="foo" /></html> |
| 120 | |
| 121 | With the render_foo method:: |
| 122 | |
| 123 | def render_foo(self, ctx, data): |
| 124 | return "Hello" |
| 125 | |
| 126 | Will result in the document:: |
| 127 | |
| 128 | <html>Hello</html> |
| 129 | |
| 130 | Note that the return value of the render method replaces the template node in |
| 131 | the DOM, so if you want the template node to remain, you should use ctx.tag. |
| 132 | |
| 133 | Built-in renderers |
| 134 | ------------------ |
| 135 | |
| 136 | Nevow comes with various built in renderers on the Page class. |
| 137 | |
| 138 | data |
| 139 | Renders the current data as-is inside the current node. |
| 140 | |
| 141 | string |
| 142 | Renders the current data as a string inside the current node. |
| 143 | |
| 144 | sequence |
| 145 | Iterates the current data, copying the "item" pattern for each item. Sets the |
| 146 | the data special of the new node to the item, and inserts the result in the |
| 147 | current node. See the nevow.rend.sequence docstring for information about |
| 148 | other used patterns, including "header", "divider", "footer" and "empty". |
| 149 | |
| 150 | mapping |
| 151 | Calls .items() on the current data, and calls ctx.fillSlots(key, value) for |
| 152 | every key, value pair in the result. Returns the template tag. |
| 153 | |
| 154 | xml |
| 155 | Inserts the current data into the template after wrapping it in an xml |
| 156 | instance. Not very useful in practice. |
| 157 | |
| 158 | nevow:data |
| 159 | ---------- |
| 160 | |
| 161 | When the nevow:data attribute is encountered, the xmlfile loader sets the data |
| 162 | special of the current node to a directive constructed with the attribute value. |
| 163 | When the template is rendered, this means that the appropriate data_* method |
| 164 | will be looked up on the current IContainer (generally the Page instance). The |
| 165 | data_* method will be called, and the result will be set as the data special of |
| 166 | the current Tag:: |
| 167 | |
| 168 | <html><div nevow:data="name" nevow:render="data" /></html> |
| 169 | |
| 170 | With the data_name method:: |
| 171 | |
| 172 | def data_name(self, ctx, data): |
| 173 | return "Hello!" |
| 174 | |
| 175 | Will result in the document:: |
| 176 | |
| 177 | <html><div>Hello!</div></html> |
| 178 | |
| 179 | Note that with a data attribute on a node but no renderer, the result of the |
| 180 | data method will be set as the data special for that tag, and child render |
| 181 | methods will be passed this data. |
| 182 | |
| 183 | nevow:pattern |
| 184 | ------------- |
| 185 | |
| 186 | When the nevow:pattern attribute is encountered, the xmlfile loader sets the |
| 187 | pattern special of the current node to the attribute value as a string. |
| 188 | Renderers which are above this node may then make copies of it using the |
| 189 | nevow.inevow.IQ of the current context. With the template:: |
| 190 | |
| 191 | <html nevow:render="stuff"><div nevow:pattern="somePattern" nevow:render="data" /></html> |
| 192 | |
| 193 | And the renderer:: |
| 194 | |
| 195 | def render_stuff(self, ctx, data): |
| 196 | pat = inevow.IQ(ctx).patternGenerator('somePattern') |
| 197 | return [pat(data=1), pat(data=2)] |
| 198 | |
| 199 | Will result in the document:: |
| 200 | |
| 201 | <html><div>1</div><div>2</div></html> |
| 202 | |
| 203 | nevow:slot |
| 204 | ---------- |
| 205 | |
| 206 | When the nevow:slot tag is encountered, the xmlfile loader constructs a |
| 207 | nevow.stan.slot instance, passing the name attribute value as the slot name. The |
| 208 | children of the slot node are added as children of the new slot instance. This |
| 209 | is useful if you wish to put patterns inside the slot. With the template:: |
| 210 | |
| 211 | <html nevow:render="stuff"><nevow:slot name="slotName" /></html> |
| 212 | |
| 213 | And the render method:: |
| 214 | |
| 215 | def render_stuff(self, ctx, data): |
| 216 | ctx.fillSlots('slotName', "Hello.") |
| 217 | return ctx.tag |
| 218 | |
| 219 | This document will be produced:: |
| 220 | |
| 221 | <html>Hello.</html> |
| 222 | |
| 223 | nevow:attr |
| 224 | ---------- |
| 225 | |
| 226 | When the nevow:attr tag is encountered, the contents of the nevow:attr node will |
| 227 | be assigned to the attribute of the parent tag with the name of the value of the |
| 228 | name attribute. Perhaps an example will be a little clearer:: |
| 229 | |
| 230 | <html><a><nevow:attr name="href">HELLO!</nevow:attr>Goodbye</a></html> |
| 231 | |
| 232 | This document will be produced:: |
| 233 | |
| 234 | <html><a href="HELLO!">Goodbye</a></html> |
| 235 | |
| 236 | While this syntax is somewhat awkward, every other type of nevow tag and |
| 237 | attribute may be used inside the nevow:attr node. This makes setting attributes |
| 238 | of tags uniform with every other method of manipulating the XML template. |
| 239 | |
| 240 | nevow:invisible |
| 241 | --------------- |
| 242 | |
| 243 | Sometimes you need to group some elements, because you need to use a |
| 244 | renderer for a group of children. |
| 245 | |
| 246 | However, it may not be desirable to give these elements a parent/child |
| 247 | relationship in your XML structure. For these cases, use nevow:invisible. |
| 248 | |
| 249 | As suggested by the name, a nevow:invisible tag is removed in the rendered |
| 250 | XML. Here is an example:: |
| 251 | |
| 252 | <html><nevow:invisible nevow:data="name" nevow:render="data" /></html> |
| 253 | |
| 254 | With the data_name method:: |
| 255 | |
| 256 | def data_name(self, ctx, data): |
| 257 | return "Hello!" |
| 258 | |
| 259 | Will result in the document:: |
| 260 | |
| 261 | <html>Hello!</html> |
| 262 | |
| 263 | xmlstr, htmlfile, and htmlstr |
| 264 | ----------------------------- |
| 265 | |
| 266 | xmlstr is a loader which is identical to xmlfile except it takes a string of XML |
| 267 | directly. |
| 268 | |
| 269 | htmlfile and htmlstr should generally be avoided. They are similar to xmlfile |
| 270 | and xmlstr, except they use twisted.web.microdom in beExtremelyLenient mode to |
| 271 | attempt to parse badly-formed HTML (non-XHTML) templates. See the nevow.loaders |
| 272 | docstrings for more information. |
| 273 | |
| 274 | Conclusions |
| 275 | =========== |
| 276 | |
| 277 | Nevow's xmlfile tag attribute language allows you to integrate |
| 278 | externally-designed XHTML templates into the Nevow rendering process. |
| 279 |
相关推荐
S4HANA - Cost Elements成本要素
SAP这里面的配置逻辑很像,就是先建一个对象,然后不停给这个对象附加一些属性,给一个账户附加编号范围,附加账户组。所有模块的维度都在这个表里,看下图的GL,CO,COPA,AA,ML的都在ACDOCA里。要把这5个类型和六大要素对应,先得把六大要素和账户类型对应下(以下是个人理解,不知道对错):当然那个C是新来的,我觉得放在资产下面也行,就不画图了。S4的嵌入式分析是在业务逻辑都整套嵌入的情况下,预开发了数据模型,所以它能提供的就不仅是原始数据了,它能提供的是包含所有相关联的上下文的信息数据。
读取xml报错问题not well-formed (invalid token): line 52, colum16
在获得想要的节点后,修改节点标签名称,然后设置xml保存的编码方式和格式属性,确保读入xml和写入后的xml文件格式保持不变。然后dom = xml.dom.minidom.parse(xml_file)例如:在xml中存在L(B*W)=DN但是python打开后出现乱码。这种情况可以先打开xml文件,其中metaxml是xml的路径字段。2、若xml中出现特殊字符,导致文件无法读取报错。就可以打开xml文件并可以读取xml的相关节点。1、若xml中出现中文字段。3、若xml修改后格式变化。
scratch航天梦主题课程作品分享,包含ppt、素材包
而今年多国都将发射探测器尝试登陆月球,2023年或将称为“登月年”,请大家发挥创新思维,以“星辰大海”为创作主题,搜集相关信息 、展开联想,为实现升空 、探测 、取样贡献创意!即使去淘宝买的素材,也要从百度网盘,但素材太多大了或者太多文件,也要充值百度网盘超级会员才能保存,提高下载速度。同学们大家好,今天我们就要开始航天主题-嫦娥五号探月工程系列的编程课程了,不仅可以学习到很多航天知识,了解本次嫦娥五号的发射历程,还能让我们用编程遨游太空呢。即使下载了,也要上传,不是特别方便,尤其是不好查找。
一篇介绍Nevow的非常好的文章,推荐
Nevow: A Web Application Construction Kit Donovan Preston <dp@divmod.org > Summary Nevow is a web application construction kit, based on the ideas developed in the Twisted Woven pack...
在Ubuntu 22.04上搞定CanFestival主站:从源码下载到SocketCAN配置的保姆级教程
本文提供在Ubuntu 22.04上配置CanFestival主站的详细教程,涵盖从源码下载、SocketCAN配置到实战测试的全过程。针对工业自动化领域的CANopen协议需求,介绍如何优化编译环境、解决常见问题,并通过虚拟CAN接口验证功能完整性。
PyBioMed学习
PyProtein。
使用twisted+nevow框架简单实例
1. 首先,编写一个HTML文件,helloword.html Hello, world! Hello, world! 2. 编写一个Nevow控制程序文件,helloword.pyfrom nevow import loaders, rendclass HelloWorld(rend.Pa
一文读懂GPU通信互联技术:GPUDirect、NVLink与RDMA
GPUDirect是NVIDIA开发的一项技术,旨在实现GPU与其他设备(如网络接口卡NIC和存储设备)之间的直接通信和数据传输,而无需CPU的参与。传统上,数据在GPU和另一个设备之间传输时,必须通过CPU,这导致潜在的性能瓶颈和延迟增加。GPUDirect技术则通过绕过CPU,直接访问和传输数据,显著提高系统性能。NVLink是NVIDIA开发的一种高速、高带宽的互连技术,用于连接多个GPU之间或GPU与其他设备(如CPU、内存等)之间的通信。
小型Python Web框架 Nevow
Nevow ,python web, zhoubols, 周波
【HFSS】仿真目录
Author: JiJi\textrm{Author: JiJi}Author: JiJi Created Time: 2026.04.27\textrm{Created Time: 2026.04.27}Created Time: 2026.04.27 Modified Time: 2026.04.27\textrm{Modified Time: 2026.04.27}Modified Time: 2026.04.27如果大家觉得有用,就点个赞吧,在阅读过程中存在任何困惑,可在下方评论区留言~
基于英特尔 RealSense D455 相机实现裂缝尺寸以及深度测量
D455 相机可用于对这些零部件进行高精度的表面检测,快速准确地测量裂缝的尺寸和深度,实现自动化的质量控制和缺陷筛查,提高生产效率和产品质量。D455 相机能够对焊缝表面进行细致扫描,测量焊缝的宽度、深度以及焊缝表面的不规则程度等参数,帮助检测焊缝是否存在缺陷,如未焊透、焊瘤等,为焊接质量的评估和改进提供数据支持。:RGB 传感器采用全局快门,并且其视场与深度视场相匹配,能够提供更出色的 RGB 图像质量,以及深度图像和 RGB 图像之间的更好对应性,从而可提高扫描质量。可以看出宽度和高度都是十分准确的。
AssertionError: Badly …
使用 gtk-builder-convert glade_hxw.glade glade_hxw.xml 最后出现如下错误 AssertionError: Badly formed XML, there is no tag. 解决方法 使用文本编辑工具打开 glade_hxw.glade,修改其中的,改成 修改为
Scratch全攻略:从入门到实践的编程之旅
Scratch 是一款由麻省理工学院(MIT)开发的图形化编程工具 ,它诞生的初衷是为了让编程教育更加普及,尤其是让孩子们能够轻松接触和学习编程。与传统的基于文本代码的编程方式不同,Scratch 通过将编程指令以图形化的积木形式呈现,极大地降低了编程的门槛,让编程变得如同搭积木一样简单有趣。
eclipse的xml文件提示templates的模板
eclipse的xml文件提示templates的模板 <?xml version="1.0" encoding="UTF-8" standalone="no"?> <templates> <template autoinsert="true" context="xml_tag" enable...
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
NTscan扫描工具
ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。
MyEclipse中xml的区别xml(advanced Templates)、xml(Basic Templates)、xml schema
advanced Templates是struts插件带的新建XML向导,可以根据Struts的配置创建基于Struts的web.xml和Struts配置文件。 Basic Templates是Eclipse带的新建XML向导,可以根据任意的DTD和Schema生成XML schema是定义和限制另一个xml文件的文件。
android 蓝牙通讯demo
android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。
使用XMLTemplater写出XML
原文地址:https://knowledge.safe.com/articles/30940/xml-writing-with-xmltemplater.html 介绍 XML是一种结构化的文本形式,常用于开放标准和交换格式。也常出现在Web和消息传递应用程序中。将数据转换成XML格式是FME的一项重要功能。本文介绍编写XML的FME方法,并且以基本的示例帮
Nevow拥有很好的新特性
引用:Nevow , a python based web construction toolkit , has a lot of nice features, that deserve attention:1 - LivePage ( Ajax ).2 - Canvas ( Flash to server ).3 - XUL , the python way.4 - Stan ( Python
Eclipse Code Templates设置
从工作开始,经历了几个项目的开发,现在的项目一般都是一个团队共同开发,而每个人都有自己的编码习惯,为了统一格式,项目组在项目开发之前都会制定一系列的规范。俗话说约定优于配置,但是在执行过程中往往发现效果不是很好(主要是指编码规范这一方面)。所以我们不得不采取一些措施来协助我们统一项目开发人员的编码风格。主要包括三个方面:设置Code Templates、Eclipse formatter、Chec...
error: Error parsing XML: not well-formed (invalid token)解决办法
从另一个工程中拷贝代码到新的工程后,编译出现了error: Error parsing XML: not well-formed (invalid token)错误,刚开始不清楚怎么解决。重新拷贝编译,也还是同样的问题。后来进入到工程中对相应的.xml文件cat看了下,发现里边全部是一些二进制的信息或者乱码。 这才发现问题所在,改用ftp服务器上传的方式后问题解决。
火狐浏览器访问网站出现 HTTP Error 400. The request is badly formed.错误,怎么解决
今天在访问某个网站时,出现一个“HTTP Error 400. The request is badly formed.”错误, 那么应该如何解决呢? 1、问题描述: 用火狐浏览网站出现“”HTTP Error 400. The request is badly formed.”错误 2、问题原因: Http error 400错误请求,是客户端问题,跟服务器没关系(也就是本地出问...
配置codetemplates.xml
/** * ${tags} */ /** * ${tags} * @功能描述: * @Author:Kvin0829 * @date:${date} ${time} * @Version:1.1.0 */ /** * @return the ${bare_field_name} */ /** @param ${param} the ${bare_field
XML解析错误
Caused by: org.xml.sax.SAXParseException; lineNumber: 80; columnNumber: 62; The content of elements must consist of well-formed character data or markup.报错原因XML解析错误查找新增加的xml文件在80行出现错误 <没有使用转义字符XML5...
2394



被折叠的 条评论
为什么被折叠?



