AGG 成果

【ACL19 论文笔记】AGGCN:基于注意力导向图卷积神经网络的关系提取模型 gua Zhijiang Guo, Yan Zhang and Wei Lu, StatNLP Research Group, Singapore University of Technology and Design; Attention Guided Graph Convolutional Networks for Relation Extraction 论文原文:https://arxiv.org/pdf/1906.07510v8.pdf 源码:https://github.com/Cartus/ 阅读详情

作为本文的结尾,这里放上一个用AGG生成不规则文字窗体的代码。它综合了我们之前学到的AGG字体引擎、坐标转换、颜色渐变等几大模 块。由于AGG的抗锯齿特性,使用生 成的窗体看上去边缘过渡非常自然,几乎看不到“毛边”。

先放上最终生成的窗体的效果:

貌似比网页左上角的logo还要好看那么一点点-_-
     #define _WIN32_WINNT 0x0501
#include <windows.h>
#include <agg_array.h>
#include <agg_pixfmt_rgba.h>
#include <agg_scanline_u.h>
#include <agg_renderer_scanline.h>
#include <../font_win32_tt/agg_font_win32_tt.h>
#include <agg_font_cache_manager.h>
#include <agg_span_solid.h>
#include <agg_span_interpolator_linear.h>
#include <agg_span_gradient.h>
#include <agg_span_allocator.h>
#include <agg_conv_transform.h>
#include <agg_ellipse.h>
#include <agg_trans_single_path.h>

typedef agg::font_engine_win32_tt_int16 fe_type;
typedef agg::font_cache_manager<fe_type> fcman_type;
typedef agg::renderer_base<agg::pixfmt_bgra32> renb_type;

// 使用指定的顶点源和线段生成器输出文字
template<class VS, class SpanGenerator>
void AggDrawText(renb_type &renb,
     fcman_type &font_manager,
     VS &vs, SpanGenerator &span_gen,
     const wchar_t *txt)
{
 using namespace agg;

 span_allocator<rgba8> span_alloc;
 rasterizer_scanline_aa<> ras;
 scanline_u8 sl;

 double x=0, y=0;
 for(const wchar_t *p = txt; *p; p++)
 {
  const glyph_cache* gc = font_manager.glyph(*p);
  if(gc)
  {
   font_manager.init_embedded_adaptors(gc, x, y);

   ras.add_path(vs);
   agg::render_scanlines_aa(ras, sl, renb, span_alloc, span_gen);

   x += gc->advance_x;
   y += gc->advance_y;
  }
 }
}

// 向renb的指定位置和半径输出http://www.cppprog.com ,有环绕效果
void DrawUrl(HDC dc, renb_type &renb,
    double ox, double oy, double rx, double ry)
{
 using namespace agg;
 //字体引擎
 fe_type font(dc);
 fcman_type font_manager(font);
 font.height(18.0);
 font.flip_y(true);
 font.hinting(true);
 if(!font.create_font("Comic Sans MS",agg::glyph_ren_outline)) return;
 //坐标转换管道
 typedef conv_curve<
  fcman_type::path_adaptor_type
 > cc_pa_type;
 cc_pa_type ccpath(font_manager.path_adaptor());

 typedef conv_transform<cc_pa_type,
  trans_single_path> ct_cc_pa_type;
 trans_single_path trans_path;
 ct_cc_pa_type ctpath(ccpath, trans_path);

 ellipse ell(0,0,rx,ry);
 trans_affine ellmtx;
 conv_transform<ellipse> ctell(ell, ellmtx);
 ellmtx.rotate(agg::pi);
 ellmtx.translate(ox,oy);
 trans_path.add_path(ctell);
 // 线段生成器
 span_solid<rgba8> ss;
 ss.color(rgba(1,0,0));

 AggDrawText(renb, font_manager, ctpath, ss, L"http://www.cppprog.com");
}
// 向renb的指定位置输出“C++编程”几个字,有镜象效果
void DrawName(HDC dc, renb_type &renb, double x, double y)
{
 using namespace agg;
 // 字体引擎
 fe_type font(dc);
 fcman_type font_manager(font);

 font.height(30.0);
 font.flip_y(true);
 font.hinting(true);
 if(!font.create_font("黑体",agg::glyph_ren_outline)) return;
 // 坐标转换管道
 typedef conv_curve<
  fcman_type::path_adaptor_type
 > cc_pa_type;
 cc_pa_type ccpath(font_manager.path_adaptor());

 typedef conv_transform<cc_pa_type> ct_cc_pa_type;
 trans_affine mtx;
 ct_cc_pa_type ctpath( ccpath, mtx );

 mtx.translate(50,50);
 //线段生成器
 span_solid<rgba8> ss;
 ss.color(rgba(0,0,0));

 AggDrawText(renb, font_manager, ctpath, ss, L"C++编程");
 // 改变坐标转换矩阵(镜像)
 mtx.reset();
 mtx.flip_y();
 mtx.translate(50,60);

 // 渐变线段生成器
 typedef span_interpolator_linear<> interpolator_type;
 trans_affine img_mtx;
 interpolator_type ip(img_mtx);

 typedef gradient_y gradientF_type;
 gradientF_type grF;

 typedef gradient_linear_color<rgba8> colorF_type;
 colorF_type colorF(rgba(0,0,0), rgba(0,0,0,0));

 typedef span_gradient<rgba8,
  interpolator_type,
  gradientF_type,
  colorF_type> span_gen_type;
 span_gen_type span_gen(ip,grF,colorF,30,80);

 AggDrawText(renb, font_manager, ctpath, span_gen, L"C++编程");
}
// 调用DrawUrl和DrawName向renb输出文字
void DrawIt(HDC dc, renb_type &renb)
{
 // 以透明色填充
 renb.clear(rgba(0,0,0,0));
 // 输出文字
 DrawUrl(dc, renb, 100, 50, 80, 40);
 DrawName(dc, renb, 50, 50);
}
// 使用AGG处理图片后与hwnd关联
void SetLayoutWin(HWND hwnd)
{
 // 起始位置和窗体大小
 POINT ptWinPos = {500,200};
 SIZE sizeWindow = {200, 100};

 // 建立DIB
 BITMAPINFO bmp_info;
 ::ZeroMemory(&bmp_info, sizeof(bmp_info));
 bmp_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 bmp_info.bmiHeader.biWidth = sizeWindow.cx;
 bmp_info.bmiHeader.biHeight = sizeWindow.cy;
 bmp_info.bmiHeader.biPlanes = 1;
 bmp_info.bmiHeader.biBitCount = 32;
 bmp_info.bmiHeader.biCompression = BI_RGB;

 HDC hdcTemp = GetDC(0);
 HDC mem_dc = ::CreateCompatibleDC(hdcTemp);
 ReleaseDC(0, hdcTemp);

 void* buf = NULL;
 HBITMAP bmp = ::CreateDIBSection(
  mem_dc,
  &bmp_info,
  DIB_RGB_COLORS,
  &buf,
  0, 0
  );

 // 把bmp与mem_dc关联,这样AGG就可以和原生GDI一起工作了
 HBITMAP temp = (HBITMAP)::SelectObject(mem_dc, bmp);
 {
  // AGG处理
  agg::rendering_buffer rbuf(
   (unsigned char*)buf,
   sizeWindow.cx, sizeWindow.cy,
   -sizeWindow.cx*4);
  agg::pixfmt_bgra32 pixf(rbuf);
  renb_type renb(pixf);
  DrawIt(mem_dc,renb);
 }

 // 把画好的mem_dc与hwnd关联到一起
 BLENDFUNCTION m_Blend={AC_SRC_OVER,0,255,AC_SRC_ALPHA};
 POINT ptSrc = {0, 0};
 BOOL bRet = UpdateLayeredWindow(hwnd, 0, &ptWinPos,
  &sizeWindow, mem_dc, &ptSrc,
  0, &m_Blend, ULW_ALPHA);
 // 回收
 ::DeleteObject(bmp);
 ::DeleteDC(mem_dc);
}

// Windows消息处理
LRESULT CALLBACK WndProc (HWND hwnd, UINT umsg, WPARAM wParam,
        LPARAM lParam)
{
 switch (umsg)
 {
 case WM_CLOSE:
  DestroyWindow (hwnd);
  return 0;
 case WM_DESTROY:
  PostQuitMessage (0);
  return 0;
 case WM_NCHITTEST:
  return HTCAPTION;
 }
 return DefWindowProc (hwnd, umsg, wParam, lParam);
}

int APIENTRY WinMain(HINSTANCE hInstance,
      HINSTANCE hPrevInstance,
      LPTSTR     lpCmdLine,
      int        nCmdShow)
{
 WNDCLASS wc={
  0,WndProc,
  0,0,
  hInstance,
  NULL,LoadCursor(NULL, IDC_ARROW),
  (HBRUSH)(COLOR_WINDOW+1),
  0,"AGGWIN"
 };
 ::RegisterClass(&wc);

 HWND hWnd = ::CreateWindowEx(WS_EX_LAYERED,"AGGWIN", NULL, WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

 if (!hWnd) return -1;
 SetLayoutWin(hWnd);
 ::ShowWindow(hWnd, nCmdShow);

 // 主消息循环:
 MSG msg;
 while (GetMessage(&msg, NULL, 0, 0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }

 return (int) msg.wParam;
}

 

<<完>>

作者:毛毛 来源:www.cppprog.com

 

 

python中使用agg方法聚合数据 使用agg方法聚合数据 agg,aggregate方法都支持对每个分组应用某函数,包括Python内置函数或自定义函数。同时这两个方法能够也能够直接对DataFrame进行函数应用操作。 在正常使用过程中,agg函数和aggregate函数对DataFrame对象操作时功能几乎完全相同,因此只需要掌握其中一个函数即可。它们的参数说明如下表。 **DataFrame.agg(func, axis=0, *args, **kwargs) DataFrame.aggregate(func, axis=0, *ar 阅读详情

相关推荐

Pandas知识点-详解聚合函数agg

pandas系列:聚合函数agg()

weixin_43790276的博客 1万+

AGG 色彩类线段生成器

色彩类线段生成器头文件#include #include #include #include #include 类型templateclass ColorT>     class agg::span_solid; templateclass ColorT, class Interpolator,

bitasd的专栏 1411

Spark聚合函数agg

agg的作用 正常情况下,当我们使用了聚合算子,后面就无法在使用其他聚合算子 而agg可以使我们同时获取多个聚合运算结果 示例 object InnerFunctionDemo { def main(args: Array[String]): Unit = { val spark = SparkSession.builder().master("local[*]").appName("function").getOrCreate() import spark.implicits._

菜鸟也学大数据的博客 5860

AGG 插值器(Interpolator)

插值器Interpolator插值器的作用是连接目标位置和源位置,比如要填充一个8*8的图形,对应的填充源是一个4*4的图像,一种简单的线性插值器就要根据目标的位置线性计算得到源对应的位置,如目标点(4,4)、(4,5)、(5,4)、(5,5)这几个位置点对应到源的(2,2)点上。头文件#include #include #include

bitasd的专栏 1099

MFC中使用agg绘制直线

<br />void CmfcaggView::OnDraw(CDC* pDC) { CmfcaggDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; RECT rt; ::GetClientRect(m_hWnd, &rt); HDC hdc = ::GetDC(m_hWnd); int width = rt.right - rt.left; i

give me five 2939

一文读懂pg AGG聚集算子计划与执行(更新中)

一文读懂openGauss/pg AGG聚集算子计划与执行Agg聚集算子与聚集操作(函数)基本概念执行策略聚集操作基本执行步骤与元数据计划生成与数据结构确定操作策略关键数据结构思考数据结构基本执行流程PLAIN-AGG并行执行流程grouping set\cube的执行策略代码走读如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart

Carrot_L的博客 3465

【亲测免费】 AGGCN:基于图神经网络的先进基因组学工具

AGGCN:基于图神经网络的先进基因组学工具 项目简介 是一个创新的深度学习框架,专门用于基因组数据的分析和预测。它利用先进的图神经网络(GNN)技术和生物信息学知识,为研究人员提供了一个强大而灵活的工具,以探索基因组中的复杂关系并进行精准预测。 技术分析 1. 图神经网络(GNN) AGGCN的核心是图神经网络,这是一种能够处理非欧几里得数据结构的强大算法。在生物学中,基因可以被视为节点,它们之...

gitblog_00002的博客 794

【Pico手势开发实战】基于SteamVR串流与MRTK3的跨平台交互方案

本文详细介绍了在Pico设备上,结合SteamVR串流与微软MRTK3框架,实现高效跨平台手势交互开发的完整方案。该方案通过在PC端运行Unity项目并串流至头显,利用MRTK3封装的手势识别与交互组件,大幅提升了开发调试效率与性能上限,并确保了未来向其他OpenXR设备的良好兼容性。

weixin_29001683的博客 216

图神经网络入门(理论篇)

图神经网络理论基础

weixin_44607838的博客 2407

SMPTE ST 2110 概论(三)

SMPTE ST 2110 概论(三)ST 2110-30:未压缩的PCM音频流ST 2110-31:非PCM音频传输ST 2110-40:辅助数据传输结语 ST 2110-30:未压缩的PCM音频流 鉴于音频系统是广播系统中最复杂,也是最重要的一套系统,我们先来回顾一下广电音频系统的历史。 最老式的音频都是基于模拟信号的,具有有限的动态范围,并且用连续的电压变化来描述音频。再后来就基于数字信号(...

Cidd0422的博客 1万+

ADS RFpro 射频阻抗仿真步骤

导入器件后,在库里面选取器件的对应模型,如图所示我们选取10pf 系统自带的村田模型。选取网络上的器件,拖入到下面component Models。导入成功后,截取需要仿真的区域(不截取仿真时间会非常长),可以生成对应如下原理图,通过原理图继续调整仿真。图上找到需要仿真链路上的网络,右键设置为信号。的叠层信息,按照PCB板厂提供信息填写完整。选择仿真的频率范围和频点数,生成如下图的RFPro仿真界。,然后再把GND也添加到下面。按图设置截取需要仿真的部分。添加成功后 网络就有了,15 双击run开始仿真。

m0_72954480的博客 3217

python pandas中的agg函数

python中的agg函数通常用于调用groupby()函数之后,对数据做一些聚合操作,包括sum,min,max以及其他一些聚合函数 如下所示: >>> df = pd.read_excel(r"D:/myExcel/1.xlsx") >>> df A B C 0 bob 12 45 1 millor 15 23 2 ...

weixin_45144170的博客 2万+

测试用例经典练习之微信发红包测试用例

微信发红包测试用例

ZCYaiCLX3344的博客 1万+

介绍 PostgreSQL STRING_AGG() 和 ARRAY_AGG()函数

本文学习如何使用介绍 PostgreSQL STRING_AGG 函数,使用分割连接多个字符串。 1. 介绍PostgreSQL STRING_AGG() PostgreSQL STRING_AGG() 函数是聚集函数,使用分隔符连接一组字符串,但结尾不会多余分隔符。语法如下: STRING_AGG ( expression, separator [order_by_clause] ) expression 可以解析成字符串的任何有效表达式。如果是其他数据类型,需要显示转换为字符串。 separa

neweastsun的专栏 8593

transformer优化(一)-UNeXt 学习笔记

​它在早期阶段使用卷积,在潜在空间阶段使用 MLP。通过一个标记化的 MLP 块来标记和投影卷积特征,并使用 MLP 对表示进行建模。 ​

PLANTTHESON的博客 2033

YOLOv8【第一章:基础入门篇·第1节】一文搞定,核心架构深度解析与环境配置!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏,该专栏专注于分享我在YOLOv8目标检测模型中的实战经验,涵盖从入门基础到深度优化的全方位解决方案。无论你是计算机视觉的新手,还是具有多年深度学习经验的专家,本专栏都将为你提供高效、可复现的技术方案,助你掌握YOLOv8的核心技术,提升目标检测性能,突破瓶颈,优化模型,并加速项目开发🚀!

**My Coding Family** 2103

如何使用agg函数对数据进行分组聚合

如果说用groupby进行数据分组,可以看做是基于行(或者说是index)操作的话,则agg函数则是基于列的聚合操作。从实现上看,groupby返回的是一个结构,这个结构必须调用聚合函数(如sum)之后,才会得到结构为的数据结果。在之前关于groupby函数的使用中,大家应该也看出来了,每次用groupby函数后,都是要接类似sum、mean等聚合函数才能输出。侦探L:如何使用groupby函数对数据进行分组(1)27 赞同 · 1 评论文章正在上传…重新上传取消而agg是DataFrame的直接方法,返回

qq_28076755的博客 3824

R语言缺失值填补|插值法、均值法、邻近法

本文主要介绍如何利用R语言进行数值型缺失值的填补。主要使用zoo包中的na.aggregate() 、na.approx()、na.locf() 函数进行缺失值的均值填补、线性插值填补以及邻近值填补。

Mrrunsen的博客 3841

string_agg 与array_agg

string_agg 数据 imos=# select res_id, res_name from test; res_id | res_name --------+---------------- 1 | Root 10001 | EC_PAG 10002 | EC_PAG_GUOBIAO (3 rows) 普通string_agg imos=# selec...

岳麓丹枫 2293

如何用 Claude Code 做代码重构,而不是重写

摘要: 在使用Claude Code进行代码优化时,AI容易“重写”而非“重构”,导致改动过大、review困难。本文提出3个关键约束方法:1)限制修改范围(如仅修改指定函数);2)明确不改变代码行为;3)要求最小必要修改。通过分步骤重构、先获取重构建议再修改、使用标准模板(保持函数签名/输入输出/结构不变)等方式,可使AI输出更符合工程需求的小范围安全重构。对于彻底混乱的代码,才建议直接重写。核心在于通过提示词精准约束AI的修改行为,将其转化为高效的代码重构助手。

sg_knight的专栏 980

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

“matplotlib.use(‘agg‘)“语句的作用机理

- 问题描述 在很多使用 matplotlib 库的代码中出现了 matplotlib.use('agg') 的语句。有些博客认为1,在导入matplotlib库后,且在matplotlib.pyplot库被导入前加“matplotlib.use(‘agg’)”语句的作用是在PyCharm中不显示绘图。例如1: import numpy as np import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt # matpl

yyywxk的博客 2万+

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

AGG AGG与FreeType库

Linux、 FreeBSD等开源操作系统里一般使用FreeType来显示文字,Windows下的一些软件如Foxit也有FreeType的身影。AGG的font_engine_freetype_int16字 体引擎就使用FreeType来取得字模,在Windows里,在使用font_engine_freetype_int16之前,我们得先编译好 FreeType:

bitasd的专栏 2355

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Pandas聚合操作 groupby和agg的用法归纳

笔者在打比赛过程中经常需要用到聚合操作,先将自己平常遇到的几种用法总结如下,便于大家和自己查询。 我们直接通过例子进行讲解,首先,我们来定义一个dataframe: import pandas as pd import numpy as np # 自定义函数,便于后面使用 def fun(arrs): res = 100 * len(arrs) return res df =...

qq_39060473的博客 1万+

pandas中聚合函数agg的用法

pandas中的聚合函数agg的用法

从此醉 9787

mysql string agg_postgresql合并string_agg函数的实例

1 有时候我们会需要将多条数据根据一些特别的字段做一些合并。比如下面这个查询,正常会查询出3条数据,但是我们会希望根据create_by 分成两列显示2 这时候需要用到string_agg函数,先通过group by分组,在进行合并,当然查询结果需要满足group by的限制;sql语句:select create_by,string_agg(videoname,",") as videoname...

weixin_42236014的博客 2341

postgre函数010-string_agg和array_agg函数的使用方法

array_agg函数 array_agg函数 将结果集返回的类型为数组,其中数组数据类型同输入数据类型一致,并以delimiter分隔符分隔,expression 表示要处理的字符类型数据。 array_agg(expression) --输入参数为任何非数组类型 string_agg 函数 语法格式如下: string_agg(expression,delimiter) string_agg 函数能将结果集某个字段的所有行连接成字符串,并以delimiter分隔符分隔,expression 表示

2344
上一篇: AGG 字体缓存管理器
下一篇: Linux 创建文件系统及挂载文件系统流程详解
bitasd
博客等级 码龄19年 11粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值