XOR neural network seems to converge around 0.5 - c

I'm trying to code a XOR neural network for some weeks, but I always face the same problem. First of all you have to know that I spent hours and hours trying all I found on the net but nothing worked.
After trying to do it using 3Blue1Brown videos on the subject without success, I am now using this http://neuralnetworksanddeeplearning.com/chap2.html. I coded a Matrix library
with all the necessary functions.
My network does have 3 layers with: 2 input neurons, 2 hidden neurons, 1 output neuron.
Moreover I have 2 biases pointing the hidden neurons, and one pointing the output neuron. I use the sigmoid function to have values between 0 and 1, and the quadratic cost function. Everytime I train the network (ie everytime I use backpropagation) I choose a random input with its corresponding output.
The problem is, whatever how many times I train it, the output is never even close to 0 or 1 but always messing around 0.5, and my cost function is stuck around 0.14.
ANY HINT OR HELP IS APPRECIATED -- I really don't get where the problem is, I feel like I've tried everything. PS: Did not show any code here, if needed, don't hesitate to say it.

I've managed to resolve my problem by adding layers in my network. Moreover, when I improved it in order to code an OCR, I added a learning rate to escape from local miminas which were partly the problem everytime my network was getting stuck.

Related

How to loop through Roblox studio to find all the humanoid and choose which is the closest one to chase? (For an Npc)

I want to make a Npc that chases the nearest humanoids (Npc or Player) and I'm not sure how to loop through workspace to do that.
I tried experimenting with for loops but I'm a noob and I need help.
Ok i figured it out but One problem though, I use this script to check whether the npc is close and if its less than 3 to damage the other fighter... (fighter.HumanoidRootPart.Position.X. - closestEnemy.HumanoidRootPart.Position.X).Magnitude < 3...but when it runs and the npcs chase each other and they Touch each other it prints 55 or 30 even though they are legit touching each other.
Get the distance between you and the entity and check if its smaller. Its very simple math

How to find a pointer in a game?

I am trying to find the offset/pointer for FIFA 22 timed finishing.
For example, if you double press "D" it will activate the timed finishing mechanic.
If you press them too quickly, too late or in the right time it will show like this "TOO EARLY" "TOO LATE" "EARLY" "GREAT TIMING"
I am trying to find this offset to modify, so everytime you shoot with timed finishing, so it will appear" GREAT TIMING" even if you don't do it right.
In FIFA 20, the offset is right here, in the attached photo.
Memory adress : 142BEC9A and you need to modify the C5 into C7, and all shots will be with green saying great timing.
But in FIFA 22, I cant' find it.
Can someone help me please, how do I know where to look? I mention I didn't found fifa 20 memory adress alone, I just got it from someone's cheat engine table.
How do I know where to find that memory adress for fifa 22 ?
https://www.youtube.com/watch?v=tk_F...channel=247CTF
Here it's a video so you can know how this game mechanic works, here in fifa 21, I had timed finishing hack activated, and as you can see, all shots were perfect.
How do I find that offset/pointer? Because it's not like searching for HP or Ammo in a shooter, to search 100, get some damage, and then do some rescan.
In the photo I posted, the adres 142BECD9A it's responsible 4for timed finishing.
The only thing I should do in that dump, is to modify the C5 into C7, and voila, all shots will be perfect.
My question is, how do you find this to modify in FIFA 22??
Ok, I don't personally own or play FIFA, but i've looked at the mechanic and can give you a few tips as to how to find it. But before that keep in mind that finding a code and knowing how to modify it is not a trivial task, like finding a value and changing it and may require you to have way more experience with cheat engine, game logic and assembly.
What you are trying to find is an instruction or instructions somewhere in the code which are responsible for figuring out how well you did the timing shot. There are many ways to get there, but my usual method is to start by finding a value very closely related to the instruction.
For example: If you are looking for an instruction that executes when the player gets damaged, you should probably find the player health, since it will likely be modified by that instruction.
With FIFA i noticed there is a bar that appears over the player's head when he does the timing shot in which bar there are lines moving towards the center. There is likely a value associated with the current value/position of that bar. Maybe when it's in the red zone the value is:10, and when it's in the green zone it might be 95-100.
To find it you can use the speedhack to slowdown your game and then search for unknown float/4 byte value and search for incremented.
Once you find the value play around with it and see if you can force it to be such that it always gives you the 'Great shot'
For changing the code:
With the value in hand you can use a 'find out what writes to that address' to find the code that modifies that value. If you can understand it and the instructions around it, you may be able to write a script that always sets it to a value that would cause it to give you 'Great timing'

changing HM reference software to display some information about the bitstream

I am very new to the HM HEVC (and the JEM) reference software, and I am currently trying to understand the source code. I want to add some lines to display for each component: name of Algo (i.e. inter/intra Algos) + length of the bitstream+ position in output bin file.
To know which component cost more bits to code and how codec is working. I want to do same thing for the JEM also after that.
my problem first is that I am unable of understanding a lot of function there, the comment is not sufficient, so is there any references to understand the code??!! (I already read the Manuel ,doesn’t help).
2nd I don’t know where & how exactly to add these lines; is it in TEncGOP, TEncSlice or TEncCU. Ps: I don’t think in TEncGOP.compressGOP so maybe in the 2 other classes.
(I put the answer to comment that #Mourad put four hours ago here, becuase it will be long)
I assume that you could manage to find where the actual encoding after the RDO loop is implemented. As you correctly mentioned, xEncodeCU is the function you need to refer to make sure you are not still in the RDO.
Now you need to find the exact function in xEncodeCU that is responsible for your target codec tool.
For instance, if you want to count the number of bits for coefficient coding, you should be looking into the m_pcEntropyCoder->encodeCoeff() (It's a JEM function and may have different name in the HM). Once you find this line in the xEncodeCU, you may do this and get the number of bits written inside encodeCoeff() function:
UInt b_before = m_pcEntropyCoder->getNumberOfWrittenBits();
m_pcEntropyCoder->encodeCoeff( ... );
UInt b_after = m_pcEntropyCoder->getNumberOfWrittenBits();
UInt writtenBitsCoeff = b_after - b_before;
One important point: as you cas see, the function getNumberOfWrittenBits() gives you integer rates, which is obtained by rounding sum of fractional rates corresponding to all syntax elements coded inside the function encodeCoeff. This error might or might not be acceptable, depending on your problem. For example, if instead of coefficient coding rate, you wanted to know the rate of CBF, then this error would not be acceptable at all. Because, CBF rate is mostly less than one bit. If this is your case, then you would need to calculate the fractional bits one-by-one. It would be totally different and relatively more complicated than this.
Point 1: There is one rule of tumb that logging coding decisions (e.g. pred mode, MV, IPM, block size) is much easier at the decoder side than encoder. This is because of the fact that you have super complicated RDO process at the encoder side that can easily make you get lost in the loops. But at the decoder side, everything appears only once. However, if you insist on doing it at the encoder side, you may find some tips here: Get some information from HEVC reference software
Point 2: Unlike coding decisions, logging rate (i.e. number of written bits for different syntax elements) is more complicated at the decoder side than encoder. This is particularly true for fractional bits associated to anything that is encoded in non-EP mode (i.e. with CABAC contexts). So you may do this part at the ecoder side. But I am afraid it is not easy.
Point 3: I think the best way to understand the code is to read it line-by-line. It's very time-consuming but if you theoritically know the standard(s), you will probably be able to distiguish important parts and ignore the rest.
PS: I think there are too many questions, mostly too general, in your post. It makes it a bit difficult for me to answer them all together. So you I'll wait for you to take your next step and ask more precise questions.

backpropagation with multiple outputs

I am currently writing a Neural Network module and I already understand how everything works with just one output. But when having multiple outputs I was told to sum up the error of each output in order to calculate the loss function, which doesn't make any sense to me, because then we don't really know which synapse/weight is responsible for the error.
For example we have a NN with the shape 2|1|2 (inputs, hidden, outputs)...
So the Neuron in the hidden layer is connected to each output neuron by some weigh. If we now propagate forward and receive an error for each output neuron and sum this error up, each weight connected with the neuron in the hidden layer is adjusted by exactly the same amount. Does someone now if I am mistaken or if I understood something wrong?
I think you misunderstood, the loss function is usually calculated individually for each output for backpropagation. If you want to know the total error in the output to track your progress, then I suppose you could use the sum of the errors for that.

How to search three or more arrays row by row for an optimum value in matlab

I have a few variables and here they are, three variables "R1, R2 and R3" each have a size of [40 x 1].
I have a fourth variable U of the same dimension. For every U(i) I need to search for an optimum value within R1(i), R2(i) and R3(i) which would return a single value solution. I intend to plot the optimum value against U9i).I have been trying to wrap my head around the knnsearch function but no luck.
Any one out there who could please help??
Thanks
Well when I can't wrap my head around something, I don't come here first.
A lot of people forget this one because we are online, but read a book on the topic. Have your code open so when you see something in the book, test it out.
Draw out any type of diagram. I call these "Napkin Diagrams", because I write it on anything, even a napkin.
I play with code until my keyboard has no letters left on it, then I keep plugging away until the keys fall off
Explore the language API's
Check for public repositories that you can play with
Google, is okay for a quick reference, but google will not teach you anything other than how to google
I talk my code over with myself all the time, people think I'm nuts, but so do I . . It actually works sometimes.
Then if I still can't get it, I come here with a list of things that I have tried, sample code that has not worked, etc.
I used to hate when people told me this, but that was the best thing anyone could have done for me so I tend to do the same now" Thinking about coding is a big part, but u have to get done wht u can. Then we all know what level u are at. Plus it being the end of semester a lot of these types of questions are homework...
Thinking is good, now turn those thoughts into a conceptual design . It's okay to be wrong in this stage, its all just conceptual
If I understood correctly, this might be what you need:
RR = [R1(:) R2(:) R3(:)];
d = bsxfun(#minus,RR, U(:));
[m mi] = min(abs(d),[],2);
answer = RR(:,mi);
first - put the three vectors into a single matrix:
RR = [R1(:) R2(:) R3(:)];
next, take the difference with U: bsxfun is ideal for this kind of thing
d = bsxfun(#minus,RR, U(:));
Now find the minimum absolute difference for each row:
[m mi] = min(abs(d),[],2);
The corresponding indices should allow you to find the "best fit"
answer = RR(:,mi);
I had to do some mind reading to get to this 'answer', so feel free to correct my misunderstanding of your problem!
update if you just need the highest of the three values, then
val = max([R1(:) R2(:) R3(:)]');
plot(U, val);
should be all you need...

Resources