matlab代码解析(一)

    xiaoxiao2021-03-25  115

    function [ opts ] = PrepareData_Char_RNN( opts ) max_char=67; x = textread('train_x.txt'); 570*65 x(:,end)=[];%去掉第二维最后一组,x变为20570*64 opts.train = zeros(max_char, size(x,1),size(x,2));%创建一个0矩阵,维数为67*20570*64 Index=x(:)'+1+max_char*[(0:numel(x)-1)];%将x变为列向量 再共轭专治,此时成为一个行向量1*1316480; %numel(x)读出矩阵x中元素个数 %(0:numel(x)-1)产生一个行向量 0到1316479, 0:3-1输出结果为0     1     2 opts.train(Index)=1;%1-K 编码 x = textread('train_y.txt'); opts.train_labels=x+1; opts.n_train=size(opts.train_labels,1); x = textread('test_x.txt'); x(:,end)=[]; opts.test = zeros(max_char, size(x ,1),size(x ,2)); Index=x (:)'+1+max_char*[(0:numel(x )-1)]; opts.test(Index)=1; x = textread('test_y.txt'); opts.test_labels=x+1; opts.n_test=size(opts.test_labels,1);
    转载请注明原文地址: https://ju.6miu.com/read-18569.html

    最新回复(0)