Tightening convex relaxations of trained neural networks: a unified approach for convex and S-shaped activations