All problems
Gradient Accumulation for Policy Updates
Problem
Compute the number of micro-batches needed to reach a global batch size: ceil(global_batch / microbatch). Return 0 when either argument is non-positive.
Hint
Accumulating micro-batches emulates a larger batch without more memory.
Test cases
case 1
in: [64,16]
expected: 4
case 2
in: [100,32]
expected: 4
case 3
in: [7,3]
expected: 3
case 4
in: [10,0]
expected: 0
Starter codePython
import math
def accumulation_steps(global_batch, microbatch):
# Your code here
pass4 test cases · run your code against them in the editor