Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Cellfun with too many outpus

조회 수: 1 (최근 30일)
Jakub Matousek
Jakub Matousek 2017년 11월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi
dynamika_skryte_vrstvy = @(x,W,b)(2/(1+exp(-(W*x+b)*lambda)))-1;
z = cellfun(@(neco) dynamika_skryte_vrstvy(x,neco,b), num2cell(W,2),'UniformOutput',false);
z = cell2mat(z);
This code leads to:
-1 -1 0,999502352199065 -1 -1 -1 -1
-1 -1 -0,913691998327500 -1 -1 -1 -1
-1 -1 0,706815080445750 -1 -1 -1 -1
-1 -1 -0,999998050022476 -1 -1 -1 -1
-1 -1 0,999996403912792 -1 -1 -1 -1
-1 -1 -0,963307663082817 -1 -1 -1 -1
-1 -1 -0,999985431635414 -1 -1 -1 -1
The third column is right output I don't know why it's giving me all other columns. I could just take the one column, but the problem is that it seems the right column is changing index based on x.... Can't say why it is at all. Can someone help, please?(W is random matrix, b is random vector)

답변 (1개)

Guillaume
Guillaume 2017년 11월 10일
I don't know why it's giving me all other columns
Because your dynamika_skryte_vrstvy function returns a row vector for the given inputs.
What are the sizes of W, x, b and lambda? At least one of these latter 3 must have 7 rows.
  댓글 수: 1
Jakub Matousek
Jakub Matousek 2017년 11월 10일
I got it needed to do this:
z = cellfun(@(neco,neco2) dynamika_skryte_vrstvy(x,neco,neco2), num2cell(W,2),num2cell(b),'UniformOutput',false);
First time working with cellfun. Need to think more next time...

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by