Logistic regression and shallow neural networks are both supervised learning algorithms used for classification problems. Logistic regression uses a logistic function to output a probability between 0 and 1, while shallow neural networks perform the same logistic calculation multiple times on inputs. Deep neural networks further extend this idea by adding more hidden layers of computation between the input and output layers. Both logistic regression and neural networks are trained using gradient descent to minimize a cost function by updating the model's weights and biases.