Extremely huge loss value

Why when I changed the coding for train_architecture() , its return value lval increases from value around 2 to value above 10000 ?

the above issue is resolved with line 765 of this git commit