check shapes of gradients