|
在尝试学习神经网络,
matlab已经提供了一个提好的看网络结构的函数。
view(net)
能看网络的结构,但是分辨率有点低,放到beamer里不太够。
找了一下,想办法得到handle,然后存成高分辨率的图。
记录下来,给以后的我\footnote{如果能活到再次使用这类图的时候}以帮助。
- clear all
- clc
- %% outline
- % example to store a net
- %% main
- % new build net -----------------------------
- net_newbuild = feedforwardnet([10,20]);
- % get the handle
- [h]=fun_mm_output_net(net_newbuild);
- % export the net to figure
- fig_name = './NN_newbuild.png';
- print('-dpng','-r100',fig_name)
- % trained net -------------------------------
- load Mat_4store_net.mat
- [h]=fun_mm_output_net(net_name);
- Iamfignameofnet = './IamNN.png';
- print('-dpng','-r200',Iamfignameofnet)
- close all
- %% logs
- % mod : 21-Apr-2017 14:37:48
- % typed by : mm
- % contact me : meatball1982@163.com
复制代码- function [h]=fun_mm_output_net(net);
- % [h]=fun_mm_output_net(net);
- % example
- %
- % load Mat_4store_net.mat
- % [h]=fun_mm_output_net(net_name);
- % Iamfignameofnet = './IamNN.png';
- % print('-dpng','-r200',Iamfignameofnet)
- jframe = view(net);
- hFig = figure('Menubar','none', 'Position',[100 100 800 180]);
- jpanel = get(jframe,'ContentPane');
- [~,h] = javacomponent(jpanel);
- set(h, 'units','normalized', 'position',[0 0 1 1])
- set(gcf,'color','w');
- %# close java window
- jframe.setVisible(false);
- jframe.dispose();
- h=gcf;
- %% logs
- % mod : 21-Apr-2017 14:32:37
- % typed by : mm
- % meatball1982@163.com
- % ref: http://stackoverflow.com/questions/14919140/matlab-how-to-save-view-configuration-of-matlab-neural-network
复制代码
|
|