The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Y.G. Bae (36) [Avatar] Offline
#1
Hello,

There are a couple of minor mistakes in the code for (5) COMPARE + LEARN: Comparing our Errors and Setting our New Weight:
1) In Python, OR operator is or, not || like C descendants or Java.
2) The last if statement should compare e_up against e_dn.
So, the correct code would be:

if(error > e_dn or error > e_up):
    if(e_dn < e_up):
        weight -= lr
    if(e_up < e_dn):
        weight += lr