如何从自动编码器中找到编码数据?

时间:2019-06-07 06:52:15

标签: python matlab autoencoder

我制作了MATLAB代码,想用python代码制作,如何将其从Matlab转换为python?

首先,我将预处理图像Matlab代码。

预处理Matlab代码以加载图像并转换为矢量:

path1 = '/home/sanjay/better Energy ImagesTUMGAID/Depth_Cropped_Fliped_Renamed_BinaryImageShifted_EnergyImage/';
list1 = dir(path1);
fName1 = {list1.name};
[~,y1]=size(fName1);
path1
count=1;
y1
xTrainImages = double([]);
xTestImages = double([]);
tTrain=[];
group1 = [];
group2 = [];
for f_no=3:50%y1
    path2=char(strcat(path1,fName1(f_no),'/'));
    list2 = dir(path2);
    fName2 = {list2.name};
    [~,y2]=size(fName2);
    for ff_no=9:y2
        group1 = [group1,f_no-2];
        path3= char(strcat(path2,fName2(ff_no)));
        image = double(imread(path3));
        max1 = max(image(:));
        image = image/max1;
        xTrainImages = [xTrainImages,image(:)];
    end
    for ff_no=3:4
        group2 = [group2,f_no-2];
        path3= char(strcat(path2,fName2(ff_no)));
        image = double(imread(path3));
        max1 = max(image(:));
        image = image/max1;
        xTestImages = [xTestImages,image(:)];
    end

end

[x1,y1] = size(xTrainImages);
[x2,y2] = size(xTestImages);
temp = [xTrainImages,xTestImages];

此处不需要预处理代码即可转换为python,仅需要与自动编码器相关的代码即可转换为python。我该怎么办?

要转换为python的Matlab代码:

rng('default');
hiddenSize1 = hds;
autoenc1 = trainAutoencoder(temp,hiddenSize1, ...
    'MaxEpochs',5, ...
    'L2WeightRegularization',0.004, ...
    'SparsityRegularization',4, ...
    'SparsityProportion',0.15, ...
    'ScaleData', false);
feat1 = encode(autoenc1,temp);

0 个答案:

没有答案