We present a real-time neural network that integrates classical and op
erant processes to describe how animals learn to escape and avoid an a
versive stimulus either by trial and error or by imitation. it is assu
med that through classical conditioning animals build an internal mode
l of the environment and that through operant conditioning animals sel
ect from alternative responses. The internal model of the environment
provides predictions of the aversive stimulus based on environmental s
timuli and the animal's own responses, and these predictions are used
to train the operant conditioning block to generate responses that min
imize the aversive stimulus. Computer simulations show that the model
correctly describes many of the features that characterize escape and
avoidance.The network also is able to describe the imitation of a demo
nstrator by an observer. During the demonstration, a neural network re
presenting the observer stores classical associations between environm
ental stimuli and the demonstrator's responses and aversive stimuli, a
nd these associations serve to train the operant associations during t
he observer's performance. it is assumed that the demonstrator's respo
nses evoke a representation of identical responses in the observer and
that the demonstrator's unconditioned response to the aversive stimul
us serves as an aversive reinforcer for the observer The network contr
ibutes to a general theory of adaptive behavior and is relevant to the
design of autonomous systems that learn either through trial and erro
r or through imitation.