I think you are missing the underscore to call uniform inplace. Besides that, that would be one way.
I would recommend to avoid using .data and use something like this instead:
with torch.no_grad():
    embedding.weight.uniform_(-scale, scale)