All problems
Null-Text Inversion Step
Problem
Apply a sequence of gradient descent updates to a null-text embedding: for each gradient vector in grads, update embedding = embedding - lr * grad in order.
The signature is null_text_inversion_step(embedding, grads, lr). Return the final embedding; an empty grads list leaves it unchanged.
Hint
Null-text inversion optimizes the unconditional embedding so a real image can be reconstructed.
Test cases
case 1
in: [[1,2],[[0.1,0.2]],0.5]
expected: [0.95,1.9]
case 2
in: [[0],[[1],[0.5]],0.5]
expected: [-0.75]
case 3
in: [[1,0],[],0.5]
expected: [1,0]
case 4
in: [[-1],[[0]],1]
expected: [-1]
Starter codePython
def null_text_inversion_step(embedding, grads, lr):
# Your code here
pass4 test cases · run your code against them in the editor