Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 6572|回复: 0
打印 上一主题 下一主题

豆粑粑 view(net) 显示神经网络结构 存图

[复制链接]

532

主题

603

帖子

3035

积分

论坛元老

Rank: 8Rank: 8

积分
3035
跳转到指定楼层
楼主
发表于 2017-4-21 14:49:03 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
在尝试学习神经网络,
matlab已经提供了一个提好的看网络结构的函数。
view(net)
能看网络的结构,但是分辨率有点低,放到beamer里不太够。
找了一下,想办法得到handle,然后存成高分辨率的图。
记录下来,给以后的我\footnote{如果能活到再次使用这类图的时候}以帮助。





  1. clear all
  2. clc

  3. %% outline
  4. % example to store a net

  5. %% main
  6. % new build net -----------------------------
  7. net_newbuild = feedforwardnet([10,20]);
  8. % get the handle
  9. [h]=fun_mm_output_net(net_newbuild);
  10. % export the net to figure
  11. fig_name = './NN_newbuild.png';
  12. print('-dpng','-r100',fig_name)


  13. % trained net -------------------------------
  14. load Mat_4store_net.mat
  15. [h]=fun_mm_output_net(net_name);
  16. Iamfignameofnet = './IamNN.png';
  17. print('-dpng','-r200',Iamfignameofnet)

  18. close all


  19. %% logs
  20. % mod : 21-Apr-2017 14:37:48
  21. % typed by : mm
  22. % contact me : meatball1982@163.com
复制代码
  1. function [h]=fun_mm_output_net(net);
  2. % [h]=fun_mm_output_net(net);
  3. % example
  4. %
  5. % load Mat_4store_net.mat
  6. % [h]=fun_mm_output_net(net_name);
  7. % Iamfignameofnet = './IamNN.png';
  8. % print('-dpng','-r200',Iamfignameofnet)

  9. jframe = view(net);

  10. hFig = figure('Menubar','none', 'Position',[100 100 800 180]);
  11. jpanel = get(jframe,'ContentPane');
  12. [~,h] = javacomponent(jpanel);
  13. set(h, 'units','normalized', 'position',[0 0 1 1])
  14. set(gcf,'color','w');
  15. %# close java window
  16. jframe.setVisible(false);
  17. jframe.dispose();
  18. h=gcf;

  19. %% logs
  20. % mod : 21-Apr-2017 14:32:37
  21. % typed by : mm
  22. % meatball1982@163.com
  23. % ref: http://stackoverflow.com/questions/14919140/matlab-how-to-save-view-configuration-of-matlab-neural-network
复制代码



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-5-4 00:16 , Processed in 0.114193 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表