You are defining accuracy as a function name and are then assigning the result to a tensor with the same name. In the next iteration accuracy would thus be a tensor (not the function anymore) and the error is raised. Change either the function or tensor name and it should work.