made theta and grad ndarrays instead of dict