赞
踩
有的层是没有的,或者没找到,但是比较简单,就自己定义一下,比如定义一个维度转置的层。
新建一个文件:
classdef transposeLayer < nnet.layer.Layer % & nnet.layer.Formattable (Optional) %% 重命名为transposeLayer properties % (Optional) Layer properties. % Declare layer properties here. end properties (Learnable) % (Optional) Layer learnable parameters. % Declare learnable parameters here. end properties (State) % (Optional) Layer state parameters. % Declare state parameters here. end properties (Learnable, State) % (Optional) Nested dlnetwork objects with both learnable % parameters and state. % Declare nested networks with learnable and state parameters here. end methods function layer = transposeLayer() %%重命名层名 % (Optional) Create a myLayer. % This function must have the same name as the class. layer.Name = "transpose"; %%层说明,会在分析的时候显示 layer.Description = "Transpose"; % Define layer constructor function here. end function [Z] = predict(layer,X) Z = permute(X,[2 1 3]);%%转置就可以了 end end end
代码写好,保存的时候会自动重命名,然后在网络调用就成了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。