Sensory-evoked firing sequences and their spontaneous replays are reproduced by applying the learning rule to recurrent neural networks with external inputs. (A) A schematic illustration of the learning of external input sequences. Filled symbols represent the firing of a neuron (vertical axis) at a certain time step (horizontal axis). Once in 50–100 time steps, at the beginning of an input episode, external input neurons fire stochastically in a fixed sequence (dark green squares when fired and empty squares when not fired). In the recurrent network, neurons respond to these inputs (brown triangles). (B) A matrix of connection weights between sequence-related neurons. We picked up the sequence-related neurons until the sixth poly-synaptic transmission via strong excitation (wij > 8.0) from the firing of the 51st external input neurons. (C) A diagram of sequential firing transmission found in the weight matrix in (B). By putting t = 0 at the first time step of an external input sequence, possible strong excitation and inhibition are drawn until t = 6. (D) Typical raster plots after learning. Colored triangles are the firing of those neurons picked up in (B). Each combination of spikes of external input neurons activates a similar but distinct firing sequence indicated by triangles of a different color. Spontaneous replays of partial sequences of the evoked activity are also repeatedly observed (indicated by arrows). The following parameters have been used in this simulation: ϵ = 0.01, cη = 2.0, cκ = 3.0, cζ = 10.0, p0 = 0.02, pmax = 0.98, N = 50, τ = 15, T = 50000.