How does a recurrent neural network (RNN) differ from a CNN?
Instruction: Compare and contrast RNNs with CNNs.
Updated
Example Answer
An RNN processes a sequence by updating a hidden state from the current input and the previous state. That gives it a compact, evolving summary of the past. A CNN applies shared filters to local neighborhoods. Those neighborhoods can be image patches, time-series windows, or text positions; CNNs are not restricted to images.
For streaming sensor data, an RNN can carry its state between readings. A causal one-dimensional CNN can also model the sequence, but its receptive field determines how much history it sees. During training, convolution often exposes more parallel work, while recurrent dependencies limit parallelism across time.
I would choose based on the required history, latency, and measured quality. LSTMs and GRUs help recurrent models retain context, but neither architecture guarantees long-range learning. Transformers are another option when their memory and latency fit the task.
Concrete Example
For an hourly forecast, a causal convolution must use the current and previous hours only. A filter that reads the next hour would leak information unavailable at prediction time.