function setHyperparametersAED(obj, varargin)
% hyperparameters, AED, input checking, defining valid inputs
%
% Purpose : With this function the hyperparameter values of the struct of
% hyperparameters can be changed.
%
% Syntax : setHyperparametersAED(obj, varargin)
%
% Input Parameters :
% - obj: AutoencoderDeep
% - vargin: name-value pairs of the fieldnames of the struct of
% hyperparamters and the corresponding values.
%
% Return Parameters :
%
% Description : This function performs input checking based on a
% pre-defined set of possible input values (data type or categorical value)
% and assigns the hypeprarameter to the new value when the checks were
% sucessfull.
%
% Author :
% Anika Terbuch
%
% History :
% \change{4.0}{14-Mar-2022}
%
% --------------------------------------------------
% (c) 2022, Anika Terbuch
% Chair of Automation, University of Leoben, Austria
% email: automation@unileoben.ac.at
% url: automation.unileoben.ac.at
% --------------------------------------------------
%
%%
% This function can only be executed when the network has not been trained.
% The hyperparameters influence the network's architecture and settings
% during training.
% %% Check if Autoencoder is trained
% if obj.Trained
% error(['This AutoencoderDeep was trained, consequently the ' ...
% 'hyperparameters can no longer be changed'])
% end
%% Check if the number of passed arguments is even - name value pairs
nrInputs = numel( varargin );
if mod(nrInputs,2)==1
error(['Unexpected number of inputs. ' ...
'The inputs need to be a name-value pairs.'])
end
%% Define struct of valid values for input assertion
%
% valid values for the hyperparmaeters of the struct which have categorical
% values
%
% the field names of this struct are constructed prefixing the fieldnames
% of the hyperparameter struct with valid and postfixing them with a s
% example: fieldname in hyperparameter-struct = LatentDim
% fieldname in this struct is validLatentDims
validVals=struct;
% numeric parameters - positive integer
validVals.validLatentDims="posInteger";
validVals.validNumberEpochs="posInteger";
validVals.validNumberFeatures="posInteger";
validVals.validMiniBatchSizes="posInteger";
% positive numeric value
validVals.validWeightingKLs="posNumeric";
%
validVals.validLearningRates="posNumericMax1";
% categorical values
validVals.validExecutionEnvironments={'cpu','gpu','auto'};
validVals.validAutoencoderTypes={'VAE','AE'};
% array of categorical values - define two 'valid Vals' - one for datatye
% one for categorical values
validVals.validLayersEncoders="categoricalArray";
validVals.validLayersDecoders="categoricalArray";
%
validVals.validLayersEncodersTypes={'FC','LSTM','Bi-LSTM'};
validVals.validLayersDecodersTypes={'FC','LSTM','Bi-LSTM'};
%
% output transfer function
validVals.validOutputTransferFunctions={'sigmoid','tanh','none'};
% arrays of positive integers, number of neurons per layers needs to be a
% positive integer; the size of each layer corresponds to an entry in the
% array
validVals.validNeuronsEncoders="posIntegerArray";
validVals.validNeuronsDecoders="posIntegerArray";
%% Devide into names and values
% odd entries are names, even entries are the corresponding values
names = varargin(1:2:nrInputs-1);
vals = varargin(2:2:nrInputs);
%% Assertion of the hyperparameters which should be changed
%
% get the struct of hyperparameters out of the object
S=obj.Hyperparameters;
% check if the passed values have valid values for the variables. The
% possible inputs (types or categorical values) are defined in the
% struct |validVals|
% iterate over the passed name-value pairs
for v=1:length(names)
% get the current name-value pair
fieldname=names{v};
fieldvalue=vals{v};
% check if the passed fieldname |fieldname| is a valid fieldname of the
% hyperparameter struct
if isfield(S,fieldname)
% construct the string which is expected to be the fieldname in the
% struct |validVals| if the |fieldname| is a valid value.
strName=char(strcat('valid',(fieldname),'s'));
% checks if for the fieldname a set of valid values is defined
% -> if the current fieldname is a field in the struct of valid
% values
if isfield(validVals,strName)
% check if in the struct of valid vals the valid values of the
% field are specified in a cell
% categorical values
if iscell(validVals.(strName))
% checks if the return array of valid strings is not empty
% checks if the passed value matches one of the specified
% values
if ~any(validatestring(fieldvalue,validVals.(strName)))
error(fieldvalue)
end
% the valid values are not specified in a cell -> data type
% specified -> check if the value should be a logical
% input or numeric input
else
% pull out the value specified in the struct of valid
% variables -> indicates of which type the variable should
% be
varType=validVals.(strName);
if varType=="posNumericMax1"
% check if passed fieldvalue is numeric and positive
% between 0 and 1
if ~isnumeric(fieldvalue) || fieldvalue > 1 || fieldvalue < 0
error(['This hyperparameter can only take ' ...
'numeric values between 0 and 1.'])
end
if (fieldvalue >1 || fieldvalue < 0)
error(['The hyperarameter LearningRate needs to be' ...
'between 0 and 1'])
end
elseif varType=="logical"
% check if the passed fieldvalue is logical
if ~islogical(fieldvalue)
error(['This hyperparameter can only take ' ...
'logical values.'])
end
elseif varType=="posInteger"
% check if the passed fieldvalue is an integer
if ~(fieldvalue == floor(fieldvalue)) || fieldvalue < 0
error(['This hyperparameter can only take ' ...
'positive integer values.'])
end
elseif varType=="posNumeric"
if ~isnumeric(fieldvalue) || fieldvalue < 0
error(['This hyperparameter can only take ' ...
'positive numeric values.'])
end
elseif varType=="categoricalArray"
if ~iscell(fieldvalue)
errorMsg=strcat(fieldname,': This hyperparameter can only take cell-arrays as its values');
error(errorMsg)
end
categoricalVals=char(strcat(strName,'Types'));
% iterate over the length of the passed array - check
% for each entry if passed entry is a valid categorical
% value
for i=1:length(fieldvalue)
% checks if the return array of valid strings is not empty
% checks if the passed value matches one of the specified
% values
ithfieldvalue=string(fieldvalue{i});
if ~any(validatestring(ithfieldvalue,validVals.(categoricalVals)))
error(ithfieldvalue)
end
end
elseif varType=="posIntegerArray"
% check if each entry of t
没有合适的资源?快使用搜索试试~ 我知道了~
具有超参数调整的时间序列自动编码器matlab代码.zip
共30个文件
m:22个
mlx:4个
pdf:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 59 浏览量
2024-04-19
22:30:36
上传
评论
收藏 1.54MB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
具有超参数调整的时间序列自动编码器matlab代码.zip (30个子文件)
具有超参数调整的时间序列自动编码器matlab代码
Matlab-AE_MVTS-main
mcode
@HyperparametersAED
setDefaultHyperparametersAED.m 4KB
HyperparametersAED.m 1KB
setHyperparametersAED.m 10KB
wrapper_functions
trainAutoencoderDeep.m 5KB
predictAutoencoderDeep.m 5KB
@AutoencoderDeep
varSeqLen2dlarray.m 4KB
decodingAED.m 2KB
setUpEncoderAED.m 4KB
squaredReconstructionErrorPerSampleAEDvariableLength.m 3KB
encodingAED.m 2KB
setUpEncoderDecoderAED.m 781B
AutoencoderDeep.m 6KB
gradientsRecErr.m 3KB
layerArray2dlnetwork.m 1KB
samplingVAE.m 3KB
reconstructionAED.m 3KB
setUpAndTrainAED.m 2KB
gradientsRecErrAndKL.m 2KB
ELBOloss.m 2KB
trainingLoopAED.m 5KB
reconstructionErrorPerSampleAEDvariableLength.m 3KB
setUpDecoderAED.m 4KB
AutoencoderDeep.png 726KB
Introduction.mlx 88KB
Preamble.mlx 5KB
Example
Example1.pdf 492KB
Example1.mlx 104KB
Example2customHyperparameterSetting.pdf 161KB
Example2customHyperparameterSetting.mlx 7KB
CITATION.cff 1KB
共 30 条
- 1
资源评论
Matlab科研辅导帮
- 粉丝: 3w+
- 资源: 7803
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Django Web框架的母婴商城实践项目设计源码
- 一个使用 Go 编程语言和 WebAssembly 构建渐进式 Web 应用程序的包 .zip
- 基于Python桌面画笔的自动画图设计源码
- 基于Java语言的中医通病例问询子系统设计源码
- 基于Java语言的云南旅游主题设计源码
- 基于Java的ExamManageSystem软件详细设计课程设计源码
- 基于Java开发的简洁方便ORM工具BeetlSQL设计源码
- 基于Java语言的Reactor-QL:用SQL简化Reactor API实时数据处理设计源码
- 基于Java的tio-http-server演示学习源码
- 基于Java和C#的C#课程实验与Winform学习及Android实验设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功