I don’t know how but when I tried executing the code with random numbers as images with size of (1280,840,3) and labels with random shapes the error doesn’t come up. It runs flawless. When I run it with my dataset with after running for 25-30 epochs it throws the illegal memory access error .  But one thing that I have observed is when I reduce the image size to (640,640,3) the execution stops at 57th - 59th epoch with the before mentioned error.  I am still not able to make out why this is happening.