The Future of Comet: Part 2, HTML 5’s Server-Sent Events

Ansys-结构动力学分析-圆柱斜齿轮模态分析学习心得 模态分析的步骤基本一直,不同点在于选择什么单元类型,模型,节点约束等 圆柱斜齿轮模态分析的难点在于圆柱斜齿轮的模型建立,和所要约束的节点的选择。 用命令流方法建立齿轮模型效率较高,当然,在ansys里建立复杂的模型实在不敢恭维,对于自下而上建模,需要知道每个关键点的坐标位置。下图是创建圆柱斜齿轮模型的命令流方式。 模型不同使用的数据也就不同了。 对于施加约束的问题这就必须要熟悉select e... 阅读详情

From: http://cometdaily.com/2008/01/10/the-future-of-comet-part-2-html-5%E2%80%99s-server-sent-events/

by Jacob RusJanuary 10th, 2008

HTML 5 and Comet

Comet doesn’t have to be a hack. Currently, as we saw last time, Comet relies on undocumented loopholes and workarounds, each one with some drawbacks. We can make Comet work effectively in every browser, using streaming transports on subdomains of the same second-level domain, or using script tag long polling across domains. But this leaves Comet developers implementing (and more frustratingly, debugging) several transports across several browsers. Traps are numerous and easy to stumble into.

Recognizing the benefit of a straight-forward, standardized Comet technique, the WHATWG’s HTML 5 specification includes sections about server-sent events, and a new event-source element, which aim to de-hackify Comet. For now, only Opera has implemented these, and its implementation remains incomplete, but both Mozilla and Apple have committed to HTML 5, and an implementation is at least in-the-works for Safari.

Every Comet developer should familiarize himself with these specifications, because they provide the best streaming transport for Opera since version 8.5, and can only grow in importance as browsers adopt them. Furthermore, HTML 5 is a work-in-progress, and now is the best time to provide feedback to the WHATWG. Those interested in the future of Comet should comment now, before the specifications have been repeatedly implemented and can no longer be easily modified.

Basics of the server-sent events data format

The server-sent events portion of HTML 5 defines a data format for streaming events to web browsers, and an associated DOM API for accessing those events, by attaching callback functions to particular named event types. The format, which is sent by a Comet server with content type application/x-dom-event-stream, is straight-forward. Each event is made up of key-value pairs. For example:

key 1: this is the value associated with key 1
key 2: this value for key 2 stretches
key 2: over three lines, which are concatenated
key 2: by a browser supporting server-sent events
; these lines, which each begin with a `;`, are
; comments, and are ignored by the browser

key 1: after a pair of newlines, this is a new
key 1: event, with its own set of key-value pairs
; the following key has an empty corresponding value
empty key

...

Each key-value pair is known as a field, and several special fields are defined in the specification. In particular, the Event field names the event as a specific type. The browser can attach different callback functions to specific named event types. If omitted, the event type is assumed to be message. Also, though it is only mentioned in examples, the data field is useful for our event payloads.

So an event stream sent by Orbited might look something like:

Event: orbited
data: this is our event payload for the
data: first Orbited event

Event: orbited
data: this is the payload for the second
data: Orbited event

Event: ping
data: /o/

Event: orbited
data: here's the third Orbited event

...

The specification mandates that all files are UTF-8, but considers any of carriage return (/r), line feed (/n), or both (/r/n) an acceptable newline—in the browser, multiple lines of a single field are joined with /n alone.

The event-source element

Server-sent events are received by objects supporting the RemoteEventTarget interface, which merely means that they support two methods, addEventSource and removeEventSource, each of which takes a URI string as input, and adds or removes it, respectively, from the list of event sources for the object.

In addition to any JavaScript objects supporting server-sent events, HTML 5 defines an event-source HTML element, which declaratively indicates the use of a Comet source in a web page. As well as supporting the addEventSource and removeEventSource methods, the event-source element has a src attribute. When the src is changed, the event-source closes its previous connection, and opens a new Comet connection to the new URI.

Cross-domain usage

HTML 5 allows connections across domains, through use of the Access-Control HTTP header, as defined in a separate W3C specification (which applies identically to normal XHR usage and to server-sent events). A request is made for a resource as usual, but if that resource on the server (in this case, an event stream from a Comet server), includes the Access-Control HTTP header with values allowing the use of the resources, browsers will treat it as if it came from the same domain as the main document. If the header is not found, or if it denies the requested use, browsers will behave as if the resource does not exist (so that denied requests reveal no information about the resource).

Additionally, HTML 5 defines a “cross-document messaging” mechanism, which allows cooperation between documents (perhaps in iframes, etc.) from different domains, using a postMessage function.

Opera’s implementation

Opera has, since version 8.5, implemented a subset of these HTML 5 technologies. Opera versions since 8.5 support the event-source element, and recent versions have pure-JavaScript interfaces as well.

To support versions back to 8.5, we must create event-source elements, set their src attribute, and attach them to the document. Then we can add “event listener” callback functions to the event-source for each type of named event in the event stream. In Orbited, we use the following JavaScript to accomplish this:

connect_server_sent_events: function () {
  var es = document.createElement('event-source');
  es.setAttribute('src', this.url);
  document.body.appendChild(es);

  var event_cb = this.event_cb;
  es.addEventListener('orbited', function (event) {
    var data = eval(event.data);
    if (typeof data !== 'undefined') {
      event_cb(data);
    }
  }, false);
},

Where this.event_cb is some callback function, a property of the Orbited object, which will receive the event payload of every orbited event. By default we send payloads in JSON format, so evaling each yields a JavaScript object.

Also, it is quite easy to test browsers for server-sent events support from JavaScript, using code something like:

if ((typeof window.addEventStream) === 'function') {
  // ... browser supports server sent events
} else {
  // ... no support.  fall back on another transport
}
Caveats

Opera’s implementation differs from the specification in a few key ways, however, so Comet application authors must be careful.

  • Opera ignores events without a defined Event field, rather than assuming its value to be message. It is possible to include multiple named event types, attaching separate event listeners for each type.
  • Event payloads must be in the data field. A callback attached to the event source will receive an event object as input, with event.data set to the value of the data field.
  • At present, Opera only supports linefeed (/n) characters as newlines in event streams, and will silently fail if carriage returns are used in newlines (/r/n and /r are not supported newlines).

Legacy support

Even though Opera is the only browser to natively implement server-sent events, it is possible for a Comet server to treat the last several versions of Safari and Firefox as if they did, with a few caveats. We can use a modified XHR streaming technique (as described in part 1), and implement our own parsing for the application/x-dom-event-stream format (at least the version supported by Opera) in JavaScript. To pull this off we must make one concession to Safari: 256 bytes of dummy data at the beginning of our event stream, so that Safari will begin incremental parsing.

Our Comet server can then be blissfully unaware that these browsers have no real server-sent event support, and we can get away with implementing only two transports on the server side: the iframe transport, supported by most browsers since at least 1999 or 2000, and—using the htmlfile ActiveX object—capable of a flawless user experience back to Internet Explorer 5.01; and server-sent events.

To make them still more compatible, we might be able to build support for event-source into Firefox and Safari using JavaScript alone, creating objects supporting the addEventSource, removeEventSource methods, and capable of dispatching named event types to event listeners. Adding such support would require deeper magic than I currently possess as a journeyman JavaScript hacker; if any masters can shed insight, please comment here, or shoot an email to the Orbited mailing list.

In Orbited, we have not yet tried reducing XHR streaming to server-sent events for Firefox and Safari, but it is on the to-do list.

Arbitrary DOM events and controversy

In addition to this straight-forward Comet transport, server-sent events provide more general, and potentially powerful, capabilities, whose complexity is somewhat controversial. Indeed, the whole server-sent events section of the specification currently includes a notice that it may be removed. I expect that it will change at least somewhat from its current form before the specification is finished.

The specification demands that every element supporting the EventTarget interface should also support the RemoteEventTarget interface. A Comet server can thereby send arbitrary DOM events to page elements. This includes events such as mouse clicks, key presses, etc. As specified, event streams can also include a Target field, which can target events to the top level of the document, or to specific element IDs. And browser vendors could, if they desired, add further objects supporting the RemoteEventTarget interface, potentially enabling declarative Comet applications.

So the theory goes. Many of us Comet developers, including Michael Carter and Alex Russell (in a recent IRC discussion), remain unconvinced that there is a benefit in pushing application logic from browser-side JavaScript to the server side. We expect that real-time applications will always have a significant need for client-side logic, so the specification may as well embrace that—and remain as simple as possible. Specification simplicity benefits not only browser vendors who must build conforming and compatible implementations but also Comet developers who must learn its ins and outs.

But I hope server-sent events are not scrapped altogether. Comet would benefit greatly from specification and intentional browser support. The version supported by Opera strikes a reasonable balance, meeting the needs of Comet developers without going beyond those needs.

Conclusion

With improving browser support, creation of more high-quality open-source Comet servers, better developer resources such as Comet Daily, and the examples provided by big-name Comet applications, Comet’s future looks bright. Any standardization efforts by browser vendors that further reduce barriers to entry will only lead to more and better Comet applications.

HTML 5 is coming, with at least Opera, Apple, and Mozilla committed to its adoption, and one way or another it will include improved Comet support. But the Comet-related portions of HTML 5 are still very much unfinished, and in need of feedback from browser vendors and from us, the community of Comet developers. The discussions are transparent and easy to join, and time for action is now. We should figure out what we need and tell the W3C and the WHATWG about it. They are all ears.

运放比较电路分析以及应用 摘要:本文介绍了基于LM321运放的同相输入型单限电压比较器电路。该电路通过运放开环工作模式实现电平判断:当输入信号Vs+>0V时输出+15V高电平,Vs+<0V时输出≈0V低电平。典型应用包括直流电压过零检测、交流信号整形、电池欠压报警和数字信号噪声过滤。电路具有结构简单(仅需1个运放和1个电阻)、成本低的优势,适用于传感器信号处理、波形转换等场景。使用时需注意参考电平调整、输出电平匹配等问题,如需抗噪声可增加正反馈电阻构成施密特触发器。该电路是运放实现简单电平逻辑的经典方案。 阅读详情

相关推荐

一体化伺服电机与施耐德PLC TM241CEC24T在Canopen协议下的应用

一.硬件组成 软件组成:施耐德SoMachineV4.3二.○1.打开SoMachineV4.3,点击“新建项目”○2.点击“空白项目”○3.项目命名○4.点击“创建项目” 三. 点击“Logic Builder” 四. ○1.右击项目”PMM_CANOPEN_ST”添加设备○2.点击”LogicController”选择PLC型号TM241CEC24T/U○3.点击“添加设备” 五. ○1.右击CAN_1,添加设备○2.选择“CANopen Perfomance”○3.点击“添加设备”

m0_46512607的博客 2540

HTML 零基础入门到企业实战全套教程【第十一章 11.5 学习总结与后续进阶路线

这一节我们做 HTML 阶段完整复盘,同时给大家一条贴合企业招聘标准、不走弯路的进阶路线:HTML → CSS → JavaScript → Vue / React,帮你把基础和就业技能衔接起来,避开新手最容易踩的 “跳过基础硬啃框架” 大坑。

wuzuhuzhanlang的专栏 221

DC-DC电源芯片SY8303电路设计

SY8303高效率同步降压DC-DC转换器。这款芯片特别适用于需要较大负载电流(高达3A)的应用。SY8303在较宽的输入电压范围(4.5V至40V)内工作,能够将输入电能高效地转换为输出电能。此外,为使运行更为稳定,SY8303集成了主要的开关和同步开关,其导通电阻(RDS(ON))非常低,可以最大限度地减少导通损耗。一些特性,如短路保护、热关断以及自动恢复等,也有助于增强其可靠性和耐用性。

LuDvei的博客 9751

Python 批量提取 HTML 中的链接:含本地文件、字符串、网页 URL

本文介绍使用 Free Spire.Doc for Python 从 HTML 中提取超链接的实用方案。通过将 HTML 加载为文档对象模型,利用其对 <a> 标签的结构化解析能力,遍历 FieldHyperlink 对象获取锚文本与 URL。核心优势在于一套代码可同时处理 HTML 与 Word 文档,适用于文档归档、内容审计等混合场景。需注意免费版存在段落与表格数量限制(500段/25表),且加载时应启用 XHTMLValidationType.none 以兼容不规范格式。对于字符串或网页来源的

Eiceblue的专栏 362

用UltraISO制作镜像以RAW格式刻录系统到U盘后,在Windows上无法识别的解决办法

在这篇文章中,用UltraISO制作镜像后,会使得U盘无法识别!!!那么,如何抹掉U盘的数据,格式化U盘呢?

拥抱具身智能,昇腾Ascend C 2744

轴承寿命预测 | 基于BiLSTM双向长短期记忆神经网络的轴承寿命预测附matlab完整代码

轴承寿命预测 | 基于BiLSTM双向长短期记忆神经网络的轴承寿命预测附matlab完整代码

默默科研仔的博客 284

HTML 零基础入门到企业实战|9.5 新手开发高频 Bug 汇总与排错思路

本节整理一线开发里新手最高频踩坑的 HTML Bug,附带错误示例、原因、修复方案,最后给一套标准化排错流程,以后遇到页面异常,不再靠瞎猜试错。

wuzuhuzhanlang的专栏 494

【音视频 ffmpeg 学习】 RTMP推流 mp4文件

3.当RTMP协议在互联网中传输数据的时候,消息会被拆分成更小的单元,称为消息块(Chunk)。1.RTMP(实时消息传输协议)是Adobe 公司开发的一个基于TCP的应用层协议。2.RTMP协议中基本的数据单元称为消息(Message)。下载地址:http://nginx.org/download。下载 rtmp模块 到nginx 模块下。安装nginx 和 rtmp模块。(1). linux 环境准备。下载nginx安装包。使用 vcl 播放流。

weixin_45397344的博客 2284

HTML 零基础入门到企业实战全套教程【第十一章 进阶拓展】1.3 主流前端框架前置知识铺垫

框架底层依旧是 DOM、事件、布局、表单、浏览器渲染这套原生机制。原生基础不牢,学框架只是背 API,很难独立排错、读懂源码、应对面试和企业项目。

wuzuhuzhanlang的专栏 668

SMOKE 3D:从 Python 到 C++ 实现车辆与行人单目 3D 视觉识别在 RK3588 上的深度部署

SMOKE的网络结构通常基于高性能的骨干网络(如DLA-34,您使用的模型就是基于此),通过编码器-解码器架构来提取特征。输入:RGB图像(本项目为骨干网络:用于特征提取。检测头热力图分支:预测关键点热力图。通常在热力图上进行NMS来找到局部最大值,即潜在的关键点位置。回归分支:对于每个关键点位置,预测上述的8维3D属性向量。分类分支:预测每个关键点对应的物体类别。置信度分支:预测每个关键点的置信度。本教程详细介绍了SMOKE单目3D目标检测模型在RK3588上的部署。我们从SMOKE的。

LXY_LOVE36的博客 444

AI奶牛TMR智能饲喂机器人 Qt信创完整项目( 统信/麒麟国产系统直接编译)

内置**犊牛、育成牛、围产牛、泌乳牛、干奶牛**5套标准化饲喂配方;+" 饲喂批次完成|牛群:"+grpText+"|投喂饲料:"+QString::number(ft)+"吨|剩料:"+QString::number(st)+"吨|异常牛:"+QString::number(abCow);cv::putText(frame,"霉变变质饲料禁止饲喂",cv::Point(20,40),cv::FONT_HERSHEY_SIMPLEX,0.7,cv::Scalar(0,0,255),2);

寒寒豆豆软件公司的博客 195

HTML 零基础入门到企业实战【第十一章 11.4】前端面试高频 HTML 知识点总结

很多同学学完 HTML 基础,写页面没问题,但是一到面试就卡壳。面试官考察 HTML,早就不只是问 “标签有哪些”,重点看语义化理解、页面渲染原理、可访问性、企业开发规范、兼容性、性能优化。

wuzuhuzhanlang的专栏 419

29、几何形态测量学在蝴蝶翅膀研究中的应用

本博客介绍了几何形态测量学在花斑木蛱蝶(Pararge aegeria)翅膀研究中的应用,探讨了环境因素对蝴蝶翅膀大小和形状的影响。通过选择合适的地标并采用Procrustes分析方法,研究揭示了不同景观类型下翅膀形状的差异及其潜在的适应性意义。文章还讨论了发育可塑性在飞行形态变异中的作用,并比较了几何形态测量学与其他传统方法的优势。最后提出了未来研究方向,包括多因素综合分析、发育机制探索及长期生态监测,为理解蝴蝶的适应性进化提供了重要线索。

ff678的博客 118

浏览器访问本地html和服务器html的流程

浏览器访问本地 HTML 和访问服务器上的 HTML,表面上看都是在浏览器地址栏输入一个地址,然后显示网页。浏览器直接从本地磁盘读取文件。浏览器通过 HTTP 协议向服务器发送请求,服务器返回 HTML 文件。从本地读取很简单,直接读取然后渲染就可以了。

d3582077的专栏 231

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

前端学习|HTML、CSS 与 jQuery 实践:选择器、DOM 读写、表单值与 Flex 布局

本文梳理 HTML、CSS 与 jQuery 实践:区分源码、DOM 与 jQuery 对象;对比文本、HTML 与表单值读写,区分属性、样式与按钮表单;说明浏览器解析修正与 Flex 主轴、交叉轴对齐规则。

Brookty的博客 389

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

FengCMS · PHP+MySQL 升级实录 · 编辑器迁移:KindEditor → wangEditor5 +服务端 HTML Purifier

回顾 KindEditor 向 wangEditor 迁移,说明编辑器适配、服务端清洗与历史内容验证的分工,并标注后来撤销的适配实验。

FungLeo's Blog 389

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

answer-me-with-html 实测

摘要(≤150字): 实测显示,answer-me-with-html 在 Codex 上使输出 token 减少约 2.5 倍(非宣传的 8 倍),因模型手写 HTML 更简洁且任务差异所致。草稿由模型生成,脚本渲染为离线网页,支持时序图、表格等组件,无外部依赖。虽有写作检查与安全策略,但组件名拼错会无声失败,存在隐患。整体提升效率,但效果受模型与任务影响,需谨慎验证输出。

guopeiAI 577

把图片塞进 HTML:Base64 内联的适用场景

把图片塞进 HTML:Base64 内联的适用场景——按实际场景给出可执行的做法与避坑要点。

xie88101802的博客 213

App Inventor WebViewer 显示动态生成的 HTML 白屏?真机与网页版差异一次讲清

App Inventor WebViewer 显示动态生成的 HTML 白屏?真机与网页版差异一次讲清 问题背景 不少从 Thunkable、Kodular 迁移过来的朋友都踩过同一个坑:应用在积木里 动态拼接出一段 HTML (比如根据用户数据算出来的表格),把它塞给 WebViewer 显示。在网页版、在线预览、甚至把 HTML 粘贴到 Chrome 里

AppInventor2中文网(https://www.fun123.cn)技术。 253

HTML 零基础入门到企业实战全套教程【10.1】综合实战|从零开发静态企业官网:需求分析、页面结构规划、素材准备

本项目是纯静态展示型企业官网,无后端、无数据库、不用 JS 复杂交互;只用 HTML + CSS 完成,后期章节再加简单 JS 轮播、表单校验。适合作为大家第一个可以放进简历的前端实战项目。

wuzuhuzhanlang的专栏 271

【教学类-07-17】20261119大3班破译电话号码HTML实际操作(添加“跳过按钮”和“返回按钮”在底部、增加“自编题目+解题”部分)

【教学类-07-17】20261119大3班破译电话号码HTML实际操作(添加“跳过按钮”和“返回按钮”在底部、增加“自编题目+解题”部分)

reasonsummer的博客 662

PHP Yii2 html css排版转PDF,包括Markdown转Html插件

本文介绍在Yii2框架中使用PHP wkhtmltopdf插件实现HTML/CSS排版及Markdown转PDF功能。通过Composer安装mikehaertl/phpwkhtmltopdf,配置wkhtmltopdf二进制路径,结合Yii2命令行工具,支持Markdown(GFM/Extra)转HTML并生成带样式、图片和表格的A4格式PDF,最终输出文件为invoice_20260418.pdf。

经验之谈,不做搬运工 70

AI 爬虫 Token 成本控制:HTML 预处理与精简方案落地

本文通过优化淘宝商品采集流程,针对原始HTML中大量冗余内容(如脚本、样式、注释、无关属性)导致大模型Token消耗过高的问题,提出基于BeautifulSoup的HTML预处理方案。通过剔除非关键标签、保留核心属性(href/src)、压缩空白字符,有效精简输入文本。实测显示,清洗后数据量显著降低,大幅减少大模型调用成本,同时保证关键信息(标题、价格、销量、链接)提取准确率,实现高效低成本的数据采集。

Echo_Vale的博客 346

环信 GitHub 仓库索引——全部SDK、UIKit 与 CallKit、Demo 与集成示例

本文档汇总环信官方及社区GitHub仓库,涵盖多端IM SDK、UIKit、CallKit组件及完整Demo,支持iOS、Android、Flutter、React Native、HarmonyOS等平台,提供快速集成与开发参考。

huan132456765的博客 222

基于微信小程序的社区疫苗预约系统-毕设源码

基于小程序的社区疫苗预约系统,采用Java + SpringBoot3后端与Vue3.4前端,实现疫苗资料浏览、接种点查询、排班选择与预约提交等全流程功能。系统设计14张核心表,遵循主键统一、状态枚举化、时间字段规范等原则,支持分页查询与并发操作。通过分层架构与严格测试,保障稳定性与可维护性,已形成闭环流程,后续将完善数据备份机制。

源码手记:一行代码一行笔记。分享 SpringBoot 3、Vue3、Python、大数据实战源码,边做边记,把项目经验留在这里。 253

副队长Vue3教程(12)--计算属性 computed

本文介绍了 Vue 3 中 computed 计算属性的用法。通过 ref 和 reactive 的响应式数据,computed 可自动推导新值,具备缓存机制,依赖不变时不重复计算,性能优于普通函数。支持只读和可写两种模式,可配置 get/set 实现双向绑定。强调其适用于同步计算场景,避免在其中使用异步逻辑或副作用。结合案例演示了输入求和等实际应用,帮助理解依赖更新与缓存机制。

编程副队长 194
上一篇: The Future of Comet: Part 1, Comet Today
下一篇: More on Long-Polling
lybra
博客等级 码龄20年 41粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值