Month: August 2024
I have PDF files on my PC that I’d like to combine into one PDF. How can I save them all in one PDF?
I have many PDF files saved on my computer, some of which are placed on the desktop, while others are in other folders. Feeling interested in placing them together to manage in one single PDF file, I went to Google to seek directions on how to do it. From that point on, Google provided several tools for merging PDFs. I tested out a few of the tools that Google suggested, but unfortunately, they do not support Windows 10, which is something I wanted because I am using Windows 10 on my computer. After that, I discovered the Pcinfotools PDF Merge Software, which combined all of my PDF files into one.
I have many PDF files saved on my computer, some of which are placed on the desktop, while others are in other folders. Feeling interested in placing them together to manage in one single PDF file, I went to Google to seek directions on how to do it. From that point on, Google provided several tools for merging PDFs. I tested out a few of the tools that Google suggested, but unfortunately, they do not support Windows 10, which is something I wanted because I am using Windows 10 on my computer. After that, I discovered the Pcinfotools PDF Merge Software, which combined all of my PDF files into one. Read More
How can I download audiobooks on Spotify to my Windows PC?
Hi,
I’ve recently started exploring the audiobook collection on Spotify and found some great titles that I’d like to listen to offline. However, since I don’t have a Spotify Premium account, I’m unsure how to download them directly to my computer.
I’m familiar with various software tools and converters, as I often use them in my work as a technical writer, but I’m not sure which one would work best for this specific task. Ideally, I’m looking for a method that can download audiobooks on Spotify in a format compatible with my PC, without compromising the quality.
Hi, I’ve recently started exploring the audiobook collection on Spotify and found some great titles that I’d like to listen to offline. However, since I don’t have a Spotify Premium account, I’m unsure how to download them directly to my computer. I’m familiar with various software tools and converters, as I often use them in my work as a technical writer, but I’m not sure which one would work best for this specific task. Ideally, I’m looking for a method that can download audiobooks on Spotify in a format compatible with my PC, without compromising the quality. Read More
Error in port widths or dimensions.
Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>>Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>> Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>> MATLAB Answers — New Questions
Give me a matlab code for plotting graph and solving the BVP. using Keller Box Method f^iv+R(f’f”-ff”’)=0 with boundary conditions f'(1)=-Φf”(0) ,f”(0)=0 ,f(0)=0,f(1)=1
…… … keller box method, matlab code MATLAB Answers — New Questions
how to fix an error:” error in port widths or dimensions.”
Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right?Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right? Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right? matlab, simulink, model predictive controller, state space representation MATLAB Answers — New Questions
iam unable to see output for open ciruit voltage of pv array. it is showing as ”nan”
Post Content Post Content unable to get output MATLAB Answers — New Questions
MS Access- Validation for post codes
Please help. I’ve been on this for 3-4 days now!
the postcodes are 4 digits… (data is in short text)
I’m trying to set up a validation rule : is null or like “####” to only enable number input or leave it blank.
no matter what I put in… numbers, letters, space… i’m getting the validation msg I set up (please enter 4 digit code)
even when I try to change the existing data (short text) same thing…
I got an error msg when trying to save this that existing data doesn’t match (seriously … just numbers in short text form)
I’m going outta my mind pls help
Please help. I’ve been on this for 3-4 days now!the postcodes are 4 digits… (data is in short text)I’m trying to set up a validation rule : is null or like “####” to only enable number input or leave it blank. no matter what I put in… numbers, letters, space… i’m getting the validation msg I set up (please enter 4 digit code) even when I try to change the existing data (short text) same thing… I got an error msg when trying to save this that existing data doesn’t match (seriously … just numbers in short text form) I’m going outta my mind pls help Read More
reckon function query
Hi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciatedHi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciated Hi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciated reckon MATLAB Answers — New Questions
How do I fix Simulink.DataType object not in scope while using c caller?
I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error?I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error? I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error? #c caller, #simulink.datatype MATLAB Answers — New Questions
Save entire Simulink model by MATLAB command
Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem?Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem? Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem? print, model, matlab, command MATLAB Answers — New Questions
How to interface simulink and display with GC9A01A driver from waveshare?
I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this?I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this? I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this? spi, gc9a01a, raspberry pi, simulink MATLAB Answers — New Questions
Parameter passing to KQL functions in Defender XDR – Body of the callable expression cannot be empty
Hi all,
In the name of maintainability, I’m trying to create functions so I don’t need to repeat myself in queries and they can all be maintained in one place.
For example, I’d like to create a function that maps a device name back to the last logged in user.
This works fine if its a query, (that is it returns results as expected if I call the function after the definition in the same file) e.g.
However, if i try saving this as a function, and then calling that from another query, I get this error:
Can anyone explain what I’m doing wrong? I’ve tried a simpler example, which also gives me the same error:
Can anyone identify what I’m doing wrong here?
Cheers,
Mitch
Hi all, In the name of maintainability, I’m trying to create functions so I don’t need to repeat myself in queries and they can all be maintained in one place. For example, I’d like to create a function that maps a device name back to the last logged in user. This works fine if its a query, (that is it returns results as expected if I call the function after the definition in the same file) e.g. However, if i try saving this as a function, and then calling that from another query, I get this error: Can anyone explain what I’m doing wrong? I’ve tried a simpler example, which also gives me the same error: Can anyone identify what I’m doing wrong here?Cheers, Mitch Read More
Android Device Enrollment Restriction- All Users Option Missing
We currently have a 3rd party MDM and are in the process of design and setup of the Intune solution. I wanted to create a default deny-all enrollment policy for personal devices until we get a solution developed so that personal smart devices don’t end up in Intune.
I set up the restriction policies for Windows, IOS and MacOS and assigned them to “All Users” just fine. When trying to do so for Android devices, the “All Users” option is missing. I have checked the all devices section and there are no devices enrolled.
Any thoughts? Thanks.
We currently have a 3rd party MDM and are in the process of design and setup of the Intune solution. I wanted to create a default deny-all enrollment policy for personal devices until we get a solution developed so that personal smart devices don’t end up in Intune. I set up the restriction policies for Windows, IOS and MacOS and assigned them to “All Users” just fine. When trying to do so for Android devices, the “All Users” option is missing. I have checked the all devices section and there are no devices enrolled. Any thoughts? Thanks. Read More
B2B Invite error
Hi,
Have been trying to invite some external users using the https://learn.microsoft.com/en-us/entra/external-id/bulk-invite-powershell.
When trying to run this line
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
I get this error
New-Object: Cannot find type [Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo]: verify that the assembly containing this type is loaded.
I have tried uninstalling and reinstalling the Microsoft.Graph module.
Any ideas what I am doing wrong?
Thanks
Hi, Have been trying to invite some external users using the https://learn.microsoft.com/en-us/entra/external-id/bulk-invite-powershell.When trying to run this line $messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfoI get this errorNew-Object: Cannot find type [Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo]: verify that the assembly containing this type is loaded. I have tried uninstalling and reinstalling the Microsoft.Graph module.Any ideas what I am doing wrong? Thanks Read More
Navigation Pane drag and drop to move
I am at a loss to understand why Outlook (new) doesn’t provided for a drag and drop feature so as to move folders and subfolders for quick organization. Being a convert to Windows from Apple, I am surprised to say the least. Apple mail has had this feature since inception. If you have a lot of Sub-folders then it gets really confusing to move them manually. Please correct me if this feature is offered or if not, is Outlook doing anything about it?
I am at a loss to understand why Outlook (new) doesn’t provided for a drag and drop feature so as to move folders and subfolders for quick organization. Being a convert to Windows from Apple, I am surprised to say the least. Apple mail has had this feature since inception. If you have a lot of Sub-folders then it gets really confusing to move them manually. Please correct me if this feature is offered or if not, is Outlook doing anything about it? Read More
ADSR Audio Envelope: How to get it?
How can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of ReleaseHow can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of Release How can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of Release envelope, adsr, audio, wave MATLAB Answers — New Questions
App UIFigure Visibility Bug
I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown.I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown. I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown. appdesigner, uifigure, visible, bug MATLAB Answers — New Questions
Accelerometer reading of pixhawk 6X using MATLAB 2024a
I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem.I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem. I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem. pixhawk 6x, matlab, simulink, sensor, uav toolbox support package MATLAB Answers — New Questions
nxn matrix as an input argument in function
function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ??function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ?? function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ?? matrix MATLAB Answers — New Questions
doubt in the backpropagation algorithm
Hi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
endHi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
end Hi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
end machine learning, backpropagation MATLAB Answers — New Questions