Have you looked into this post?

  
    
    
    What is the best way to apply k-fold cross validation in CNN? 
  
  
    Hello, 
How can I apply k-fold cross validation with CNN. I do not want to make it manually; for example, in leave one out, I might remove one item from the training set and train the network then apply testing with the removed item. Could you please help me to make this in a standard way. 
Regards,