Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. def batchGenerator(imgs, steerings, batchSize, isTraining):
  2.  
  3. while True:
  4. batchImg = []
  5. batchSteering = []
  6.  
  7. for i in range(batchSize):
  8. randIndex = random.randint(0, len(imgs) - 1)
  9. if isTraining:
  10. img, steering = randomAugment(imgs[randIndex], steerings[randIndex])
  11. else:
  12. img = imgs[randIndex]
  13. steering = steerings[randIndex]
  14.  
  15. img = imgPreprocess(img)
  16.  
  17. batchImg.append(img)
  18. batchSteering.append(steering)
  19.  
  20. yield (np.asarray(batchImg), np.asarray(batchSteering))
  21.  
  22. history = model.fit_generator(batchGenerator(X_train, y_train, 300, 1),
  23. steps_per_epoch = 300,
  24. epochs = 10,
  25. validation_data = batchGenerator(X_valid, y_valid, 200, 0),
  26. validation_steps = 200,
  27. verbose = 1,
  28. shuffle = 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement