function Z = UpdateZ(Z, Y, gamma, alpha, Ppool, Jpool, Fpool, num_class,WXb)

ITER = 100;
conv = zeros(1,ITER);
lr = 0.0001;


for it=1:ITER
    tmp = zeros(size(Z));
    for i = 1 : num_class
        curP = Ppool{i, 1};
        curJ = Jpool{i, 1};
        curF = Fpool{i, 1};
        tmp = tmp + curP'*( curJ.*(curP*Z - curF) ); 
    end
    
    grad = (Z - WXb) + gamma*(Z - Y) + alpha*tmp;
    Zold = Z;
    Z = Z-lr*grad;
    
    conv(it) = norm(Z-Zold,'fro');
    
    if it>1
        if abs(conv(it)-conv(it-1))<0.0001*conv(it)
            break
        end
    end
    
end


end