## Abstract

Errors in stimulus estimation reveal how stimulus representation changes during cognitive processes. Repulsive bias and minimum variance observed near cardinal axes are well-known error patterns typically associated with visual orientation perception. Recent experiments, however, suggest that these errors continuously evolve during working memory. Here, we demonstrate that a network can produce correct error patterns in delayed estimation when fulfilling two distinct functions: efficient sensory encoding and memory maintenance. No single-module network can satisfy these demands simultaneously. Instead, network interaction between sensory-memory modules is essential. The sensory module exhibits heterogeneous tuning with strong inhibitory modulation that reflects natural orientation statistics. While the memory module alone supports homogeneous memory representation via continuous attractor dynamics, the fully connected network forms discrete attractors but with moderate drift speed and nonuniform noise for accurate variance patterns. Together, our work underscores the significance of sensory-memory interaction in continuously shaping stimulus representation during working memory.

## 1 Introduction

The brain does not faithfully represent external stimuli. Even for low-level features like orientation, spatial frequency, or color of visual stimuli, their internal representations are thought to be modified by a range of cognitive processes, including perception, memory, and decision ^{1-3}. Experimental studies quantified such modification by analyzing behavior data or decoding neural activities. For instance, biases of errors, the systematic deviation from the original stimuli, observed in estimation tasks have been used as indirect evidence ^{4}.

One important source of biases is adaptation to environmental statistics, such as nonuniform stimulus distribution in nature. Cardinal repulsion, which refers to the systematic shift away from the horizontal and vertical orientations observed in many perceptual tasks, is one of the examples ^{5}.

Theoretical works suggest that such a bias pattern reflects the prevalence of the cardinal orientations in natural scenes ^{6}. Similarly, the variance of errors for orientation stimuli was found to be inversely proportional to the stimulus statistics, minimum at cardinal and maximum at oblique orientations ^{7}. It was postulated that the dependence of biases and variance of errors on natural statistics results from sensory encoding optimized to enhance precision around the most common stimuli ^{4,8,9}.

On the other hand, there is a growing body of evidence indicating that error patterns are not solely influenced by sensory encoding but are also shaped by memory processes. In delayed estimation tasks, where participants are presented with stimuli followed by a delay period during which they rely on their working memory for estimation, it has been observed that representations of orientation or color stimuli undergo gradual and continuous modifications throughout the delay period ^{10-12}. Such dynamic error patterns are inconsistent with sensory encoding models, most of which only establish a static relationship between stimuli and internal representations. Traditional working memory models are not suitable either. Most of them are constructed to faithfully maintain information about stimuli during the delay period, and thus, the memory representation has a similar geometry as that of the stimuli ^{13,14}. For continuous stimuli such as orientation, location, direction, or color, all stimuli are equally maintained in ring-like memory activities, predicting no biases ^{15-17}.

How can we explain error patterns in both perception and working memory tasks? Here, we claim that not a single module but a two-module network with recursive interaction is required. Each module has a distinct role — sensory encoding and memory maintenance. To illustrate this, we use orientation stimuli and examine how their representations change during the delayed estimation tasks. We employ two approaches to find solutions for generating correct error patterns. The first extends previously suggested sensory encoding models, while the second modifies low-dimensional memory models based on attractor dynamics. These approaches are integrated into the network models, which link network connectivity to neuronal tuning properties and behavioral error patterns and reveal the attractor dynamics through low-dimensional projection. Our results show that the sensory-memory interacting networks outperform single-module networks with better control over the shapes and evolution of dynamic error patterns. Furthermore, our network models emphasize the importance of inhibitory tuning in sensory circuits for generating correct error patterns under typical associative learning of natural statistics. Finally, we provide testable predictions regarding the effect of perturbations in sensory-memory interactions on error patterns in delayed estimation tasks.

## 2. Results

### Low-dimensional attractor models

In natural images, cardinal orientations are the most prevalent (**Fig. 1a**). Error patterns in estimation tasks show dependence on such natural statistics, such as biases away from cardinal orientations where the variance of errors is nonetheless minimal (**Fig. 1b,c**). In delayed estimation tasks, such a bias pattern is consolidated in time (**Fig. 1b**). Also, experimental data suggested that estimation errors increase with a longer delay ^{18,19}, while the precision is still highest at cardinal orientations ^{7,20,21}. Thus, we assumed that the variance of errors increases as keeping its characteristic shape (**Fig. 1c**). To explain these errors across orientations and over time, we first explored the underlying working memory mechanism. We considered low-dimensional attractor models with input noise that describe the drift and diffusion of the memory states. Here, we show that two prominent classes of previously suggested models are inconsistent with experimental observations and examine what modification to the models is required.

The most widely accepted model for working memory of orientation stimuli has continuous attractor dynamics, which assumes that all orientations are equally encoded and maintained (**Fig. 1d-f**). Each attractor corresponds to the memory state for different stimuli and forms a continuous ring following the geometry of orientation stimuli. The dynamics along continuous attractors are conceptually represented as movement along a flat energy landscape (**Fig. 1d**). Without external input, there is no systematic shift of mean activity, that is, no drift during the delay period (**Fig. 1e**). Also, under the assumption of equal influence of noise for all orientations, the variance of errors is spatially flat with constant diffusion along the ring, while the overall magnitude increases over time due to the accumulation of noise (**Fig. 1f**).

While such continuous attractor models have been considered suitable for memory storage of continuous stimuli, they cannot capture drift dynamics observed during the delay period. Instead, discrete attractor models with uneven energy landscapes have been suggested with the energy wells corresponding to discrete attractors (**Fig. 1g-i**). As evolution toward a few discrete attractors creates drift dynamics, the bias increases during the delay (**Fig. 1h**). Also, discrete attractor models naturally produce nonuniform variance patterns. Even with constant noise along the ring, variance becomes minimum/maximum at the attractors/repellers due to the drift dynamics (**Fig. 1i**). However, discrete attractor models with constant noise yield inconsistent results when inferring the locus of attractors from the bias and variance patterns observed in data. Cardinal orientations should be the repeller to account for cardinal repulsion. In contrast, the minimum variance observed at the cardinal orientations suggests they should be the attractors.

How can such inconsistency be resolved? One possible solution is discrete attractor models with nonuniform noise amplitude (**Fig. 1j**). Let’s consider that attractors are formed at oblique orientations to generate correct bias patterns (**Fig. 1k**). Additionally, we assumed that noise has the highest amplitude at the obliques. When the difference in the noise amplitude is large enough to overcome the attraction toward the obliques, the models can produce correct variance patterns, maximum at the obliques and minimum at cardinal orientations (**Fig. 1l**). In sum, unlike two prominent memory models, continuous attractors or discrete attractors with constant noise, discrete attractors with maximum noise at the obliques could reproduce experimentally observed error patterns of orientation stimuli. Note that these attractor models often simplify the full network dynamics. Namely, the drift and diffusion terms are derived by projecting network dynamics onto low-dimensional memory states ^{22,23}. Thus, it is still in question whether there exist memory networks that can implement attractor dynamics with correct drift and diffusion terms.

### Bayesian sensory model and extension

Before exploring full memory network models, we note that previous theoretical works for sensory processing suggested that Bayesian inference with efficient coding could generate the repulsive bias and the lowest variance at cardinal orientations ^{4,9}. Efficient coding theory suggests the sensory system should enhance the sensitivity around more common stimuli. For orientation stimuli, precision should be highest around cardinal directions, which could be achieved by sharpening the likelihood functions. Equipped with Bayesian optimal readout, such a sensory system could reproduce correct error patterns observed in perceptual tasks for various visual stimuli, including orientations (**Fig. 2**).

However, such models only account for the relationship between external and perceived stimuli during sensory processing, resulting in static error patterns. Here, we extended the framework so that the system can maintain information about the stimulus after its offset while bias and variance of errors grow in time (**Fig. 2a**). We added a memory stage to Bayesian sensory models such that the memory stage receives the output of the sensory stage and returns it as the input after the maintenance. For instance, let’s denote the external orientation stimulus given during the stimulus period as *θ*_{1}. The sensory stage receives *θ*_{1} as input and generates the perceived orientation, , which varies trial-to-trial with sensory noise (**Fig. 2b**). Through the memory stage, is returned as the input to the sensory stage for the next iteration with the addition of memory noise *ξ*_{1}.

Such a recursive process mimics interactions between sensory and memory systems where the sensory system implements efficient coding and Bayesian inference, and the memory system faithfully maintains information. As the recursive process iterates, the distribution of the internal representation of orientation broadens due to the accumulation of noise from the sensory and memory systems. This leads to an increase of bias and variance at each step while keeping their characteristic shapes (**Fig. 2c**). Thus, recurrent interaction between sensory and memory systems during the delay period, each of which meets different demands, successfully reproduces correct error patterns observed in both perception and memory tasks.

### Network models with sensory and memory modules

Next, we construct network models capturing the sensory-memory interactions formalized under the Bayesian framework. We consider two-module networks where each module corresponds to the sensory and memory systems. To generate orientation selectivity, both modules have a columnar architecture where neurons in each column have a similar preference for orientation (**Fig. 3a**). However, their connectivity structures are different (**Fig. 3b**). The memory module in isolation resembles the traditional ring attractor network with a strong and homogeneous recurrent connection. This enables the memory module in isolation to maintain information about all orientations equally during the delay period (**Fig. 3b-f**, right). Conversely, the recurrent connectivity strengths in the sensory module are relatively weak, such that without connection to the memory module, the activities during the delay period decay back to the baseline levels (**Fig. 3b**, left). Furthermore, the connectivity strengths across columns are heterogeneous, particularly stronger at the obliques. As a result, the tuning curves near cardinal orientations can be sharper and denser, consistent with experimental observations showing a larger number of cardinally tuned neurons ^{24,25} and their narrower tuning ^{24,26} (**Fig. 3c-f**, left). Different response activities of the two modules in isolation are demonstrated in their response manifolds as sparser representations around cardinal orientations in the sensory module, compared to the ring-like geometry of the memory module (**Fig. 3f**).

For sensory-memory interacting networks, we connected the two modules with inter-module connections set to be stronger between neurons with similar orientation selectivity (**Fig. 4a**). Activity profiles in both modules follow that of the sensory module — heterogeneous with narrower and denser tuning curves around cardinal orientations, leading to higher sensitivity (**Fig. 4b**). Such activity pattern is maintained even during the delay period when recurrent connections in the memory module support activities of both sensory and memory modules (**Fig. 4b**, right). Note that while sensory activities convey stimulus information during the delay period, their overall firing rates are much lower than those during the stimulus period with weak interconnection strengths. Such low firing rates may lead to both positive and negative evidence of sustained activity in early sensory areas ^{27}.

When the internal representation of the orientation stimulus is read from the memory module, the sensory-memory interacting network exhibits repulsive bias and minimum variance at cardinal orientations, inheriting from efficient sensory coding (**Fig. 4c,d**). Such bias increases during the delay period with increasing asymmetry of tuning widths despite lower firing rates than the stimulus period (**Supp Fig. 1**). At the same time, errors gradually increase due to noise accumulation in time, as in typical memory networks ^{16,22}. We obtained Fisher information measuring sensitivity at each orientation from the neural responses (see **Methods**). Opposite to the variance of errors, Fisher information is highest at cardinal orientations, while it decreases during the delay period (**Fig. 4e**). Thus, the sensory-memory interacting network model that mechanistically embodies the extension of the Bayesian sensory model correctly reproduces the error patterns observed in delayed estimation tasks.

### Analysis of low-dimensional memory states

To further understand the mechanisms of generating the correct error patterns in sensory-memory interacting networks, we analyzed the network dynamics during the delay period. For this, we identified the low-dimensional manifold that has slow dynamics during the delay period, which corresponds to the memory states (**Fig. 5a**). We projected the dynamics along this manifold to obtain the drift and diffusion terms (**Fig. 5a-c**; **Supp Fig. 2**). The drift term shows similar patterns to cardinal repulsion (**Fig. 5b,e**). Integrating this drift for orientation yields the energy function, which is minimum at the obliques (**Fig. 5d**). This suggests that the network implements discrete attractor dynamics with attractors formed at the obliques. The diffusion term is also uneven — the noise amplitude is maximum at the obliques so that despite attraction toward them, the variance of errors can be maximum (**Fig. 5c,f**). The nonuniform characteristics of both drift and diffusion processes align with the solution identified in low-dimensional memory models (**Fig. 1j-l**).

Next, we examined how heterogeneity of connectivity in the sensory module affects the dynamics along the memory states. The magnitude of heterogeneity is denoted as α, and larger α represents a larger asymmetry of connectivity strengths at cardinal and oblique orientations (**Fig. 3b**, left). When α increases, the asymmetry of drift and energy levels becomes more prominent, leading to a more rapid increase in bias (**Fig. 5b,d,e**). The diffusion term is also more asymmetric, compensating for stronger attraction to the obliques (**Fig. 5c**). Thus, for larger α, the variability of errors is still higher at the obliques (**Fig. 5f**). We also note that the overall increase of intermodal connectivity strengths has similar effects, which enhances the influence of the heterogeneity in the sensory module on the network dynamics (**Supp Fig. 3**).

In sum, network models emphasizing the interactions between sensory and memory modules can embrace solutions found under two separate approaches, one among low-dimensional memory models with attractor dynamics and the other by extending the Bayesian sensory system. The asymmetry of drift and diffusion terms, and thereby, the bias and variability of errors, are determined by the degree of heterogeneity in the sensory module or its influence on the overall dynamics.

### Importance of heterogeneously tuned inhibition

We showed that network models realizing sensory-memory interactions reproduce correct error patterns, where each module has a different connectivity structure. Previous work suggested that such a heterogeneous connection of the sensory system may arise from experience-dependent synaptic modification ^{28,29}. For example, typical Hebbian learning is thought to potentiate connectivity strengths between neurons whose preferred stimuli are more frequently encountered. For orientations, cardinal directions are predominant in natural scenes. Thus, if experience-dependent learning occurs mainly at the excitatory synapses, the excitatory connections near cardinal orientations become stronger in the sensory module. This is opposite to the previously discussed case where the sensory module has the strongest connection at the obliques. With the strongest excitatory connections at cardinal orientations, the error patterns are reversed, resulting in cardinal attraction instead of repulsion, and the lowest variance occurs at the obliques.

Inhibitory synaptic connections can also be modified through learning ^{30-32}. Here, we considered that experience-dependent learning exists in both excitatory and inhibitory pathways and similarly shapes their connectivity (**Fig. 6a**). We assumed that excitatory and inhibitory connections are segregated and stronger near cardinal orientations (**Fig. 6b**). We modulated the heterogeneity degree of both excitatory and inhibitory connections, denoted as α and β, respectively (**Fig. 6b-d**). The ratio between α and β determines the direction and magnitude of bias and variance patterns (**Fig. 6c,d**). For relatively larger α, the network shows cardinal attraction and minimum variance of errors at the obliques (**Fig. 6e**). Reversely, for relatively larger β with stronger modulation in inhibitory connections, the network reproduced cardinal repulsion and minimum variance of errors at cardinal orientations, consistent with experiments (**Fig. 6f**). With a larger difference between α and β, such patterns of bias and variance are potentiated and minimum Fisher information across orientations decreases, corresponding to the memory loss (**Fig. 6c,d**; **Supp Fig. 4**). Thus, this emphasizes the important role of heterogeneously tuned inhibition in shaping the sensory response for higher precision at cardinal orientations and enabling the sensory-memory interacting network to generate correct error patterns.

### Comparison to alternative circuit structures

So far, we have shown the sufficiency of sensory-memory interacting networks with different connectivity structures featuring heterogeneous-homogeneous recurrent connections within each module. Here, we explore whether such architecture is necessary by comparing its performance with alternative circuit structures for sensory-memory interactions. We assumed that sensory and memory modules still serve their distinctive functions, namely, sensory encoding and memory maintenance, with weak/strong recurrent connections in sensory/memory modules. On the other hand, the heterogeneity of connections in other circuits might differ as homogeneous-homogeneous, homogeneous-heterogeneous, and heterogeneous-heterogeneous connections for sensory-memory modules.

Circuits with homogeneous connections in both sensory and memory modules are similar to previous continuous attractor models for working memory, such that the energy landscape and noise amplitude are uniform for all orientations (**Fig. 1d-f**). Such architecture is not suitable as it generates no bias in errors and flat variance patterns. This leaves the latter two types of configurations, which require heterogeneous connections within the memory module. With a strong recurrent connection within the memory module, its heterogeneous activity pattern dominates overall activities in sensory-memory interacting networks, which makes it analogous to an isolated memory module. Thus, we examined the property of the memory module alone, which can maintain memory while generating heterogeneous responses without connection to the sensory module (**Fig. 7**).

To generate the correct bias pattern, we assumed that excitatory and inhibitory pathways in the memory module are stronger near cardinal orientations, as we previously considered for the sensory module in the sensory-memory interacting network (**Fig. 7a,b**). However, memory circuits with heterogeneous connections have problems in maintaining the information and reproducing correct error patterns (**Fig. 7c-e**). First, memory circuits alone require fine-tuning of heterogeneity whose range generating a moderate drift speed is at least one order of magnitude smaller than that of the two-module network (**Fig. 7c,d**). Deviation from this range results in fast drift toward oblique orientations, leading to rapid loss of information during the delay period (**Supp Fig. 4**). Second, despite the correct bias direction, the variance pattern is reversed such that the variance of errors is minimal at the oblique orientations (**Fig. 7e**). Varying the heterogeneity in excitatory and inhibitory connections shows that such rapid drift and reversed error patterns are prevalent across different parameters (**Fig.7c,d**).

To understand why a heterogeneous memory circuit alone fails to reproduce correct error patterns, we compared its low-dimensional dynamics along the memory states to that of the sensory-memory interacting networks. For the network with a similar range of bias and variance on average, we compared their energy landscape and noise amplitude, which vary similarly in both networks with minimum energy level and maximum noise at the oblique orientations (**Supp Fig. 5**). However, the energy difference between cardinal and oblique orientations in a single memory-circuit model is bigger than that in a sensory-memory interacting network. In contrast, the difference in noise amplitude is smaller. The attraction at the obliques is much stronger, leading to the correct bias patterns, but too rapid increase. Also, smaller differences in noise amplitude cannot overcome strong drift dynamics, leading to the minimum variance of errors at the obliques and reversed variance patterns. This suggests that compared to a heterogenous memory circuit alone, interactions between heterogeneous sensory and homogeneous memory modules are advantageous due to better control of energy and noise difference at cardinal/oblique orientations.

## 3. Discussion

While higher association areas have long been considered as a locus of working memory ^{33,34}, recent human studies found memory signals in early sensory areas, prompting a re-evaluation of their role in working memory ^{35,36}. Our work extends the traditional memory models ^{13,14} with novel insights into the significance of stimulus-specific sensory areas. We showed how sensory-memory interactions can elucidate changes in the internal representation of orientation stimuli and their behavioral readout during memory tasks. The observed error patterns suggest that the network meets two demands simultaneously: efficient encoding that reflects natural statistics and memory maintenance for successful retrieval of stimuli after a delay. Achieving both demands for orientation stimuli conflicts in a one-module network. Efficient encoding necessitates asymmetrical connections, resulting in inconsistent bias and variance patterns and overly rapid drift in the one-module network unless fine-tuned. In contrast, connecting sensory and memory modules can generate error patterns correctly and with less need for fine-tuning heterogeneity for slow drift. Efficient coding of natural statistics in the sensory module underscores the role of inhibitory plasticity. Low-dimensional projection onto memory states reveals that drift and diffusion processes governing working memory dynamics closely resemble the bias and variance patterns derived under Bayesian sensory models. It also elucidates how the magnitudes of bias and variance change depending on the heterogeneity of sensory connections.

Our model makes testable predictions to differentiate two-module and one-module networks using perturbation, such as transcranial magnetic stimulation (TMS). Many studies have found that during the delay period, TMS can intervene with the feedforward signal from sensory areas through which working memory is consolidated ^{37} (but see ^{36} for mixed effects of TMS and related debate). Under such perturbations, the ability to maintain information in the memory module will not be affected due to strong recurrent connections in both two-module and one-module networks. However, we expect different effects on bias patterns — in the two-module network, the bias will stop systematically drifting towards the obliques, reducing systematic repulsion (**Figure 8**). This accompanies the nonincreasing heterogeneity of tuning curves after the disruption, marked by their tuning width indices (see **Methods**). In contrast, in the one-module network, perturbation does not incur changes in error patterns as memory activities are less dependent on the sensory module during the delay period. Thus, perturbation studies can be used to reveal the role of the sensory module in shaping the error patterns during working memory. Note that our model cannot predict the effects of distractors during working memory, as such effects do not experimentally lead to changes in error patterns ^{38}. The effect of distractors and direct intervention in the inter-module connections may differ due to potential differences in the encoding of distractors compared to task-relevant stimuli. More advanced models are required to comprehensively understand the influence of distractors and the processing of ongoing visual stimuli or the storage of multiple stimuli.

Our work suggests biologically plausible network mechanisms for the previously postulated efficient coding and Bayesian inference principles, relating network connectivity to tuning properties and error patterns. Previous normative explanations for systematic bias observed in perception tasks also suggested possible neural substrates for efficient coding, such as asymmetrical gain, width, or density of tuning curves across stimulus features ^{8,9}. Our work narrowed the mechanism to denser and narrower tuning curves at cardinal orientations, consistent with neurophysiological recordings in the visual cortex ^{24-26}. We implemented a population vector decoder reflecting neuronal preferred orientations, which approximates Bayesian optimal readout ^{39}. Compared to a previous work adapting efficient coding theories with static tuning curves to account for error patterns in working memory tasks ^{40}, our extension to memory processes demonstrated how neural activities and behavior readout change dynamically during the delay period. Notably, recent work combined dynamic change of signal amplitude with static tuning curves to capture different time courses of estimation precision during sensory encoding and memory maintenance ^{41}. Our network models embody such phenomenological models as the networks exhibit changes in overall firing rates after the stimulus offset.

Like our study, a few recent studies have employed attractor dynamics to explain dynamic error patterns observed for visual color memory ^{11,42,43}. Behavior studies showed attractive bias and minimum variance around the prevalent colors, which one-module discrete attractor models could reproduce. However, these models cannot be generalized to other visual stimuli, such as orientations, spatial locations, or directions, of which the responses show repulsive bias away from the common stimuli ^{4}. Also, a one-module network storing color memory requires fine-tuned heterogeneity for moderate drift speed. While the desired low-dimensional manifold and drift dynamics can be engineered in the one-module network ^{42}, its biological mechanism needs further investigation. The two-module network considered in our study also requires fine-tuning of homogeneity in the memory module and heterogeneity in the sensory module. However, the condition of asymmetrical connections in the sensory module is less stringent as they have a weaker influence on the entire dynamics than those in the memory module. Fine-tuning of homogeneous connections in the memory module can be mediated through activity-dependent plasticity, such as short-term facilitation ^{44-46} or long-term plasticity ^{47,48}. Also, recent work showed that continuous attractors formed under unstructured, heterogeneous connections are robust against synaptic perturbations ^{23}. Thus, the two-module networks can control the drift speed better with possible additional mechanisms that promote homogeneous memory states. It needs further exploration whether they can be generalized to other stimuli like color, possibly involving additional categorical structures ^{49,50}.

The modularity structure in the brain is thought to be advantageous for fast adaptation to changing environments ^{51-53}. Recent works showed that recurrent neural networks trained for multiple cognitive tasks form clustered neural activities and modular dynamic motifs to repurpose shared functions for flexible computation ^{54,55}. Resonant with these computational findings, an fMRI study showed that shared representation across distinct visual stimuli emerges during the delay period ^{56}. Although our work focuses on a single task, it highlights the necessity of having dedicated sensory and memory modules, and a memory module with ring geometry can be repurposed for various visual stimuli such as motion, spatial location, and color. It is reminiscent of the flexible working memory model, which proposes connections between multiple sensory modules and a control module ^{57}. However, a key distinction lies in the role of the control module. Unlike the flexible working memory model that loses memory without sensory-control interactions, our work suggests that the memory module can independently maintain memory, while interaction with the sensory module continuously shapes the internal representation, potentially consolidating prior beliefs regarding natural statistics. The sensory-memory interaction and network architecture derived from dynamic changes of single stimulus representation can be a cornerstone for future studies in more complex conditions, such as under the stream of visual inputs ^{35,36} or with high or noisy memory loads ^{3}.

## 4. Methods

### Low-dimensional attractor models

To illustrate error patterns in different low-dimensional attractor models shown in **Figure 1**, we considered a one-dimensional stochastic differential equation given as
where *θ*_{t} and *W*_{t} are orientation and standard Brownian motion at time t. We assumed that the drift and noise coefficients *μ* and *σ* only depend on *θ*_{t} where with diffusion coefficient 𝒟.

For continuous attractor models in **Figs. 1d-f**, *μ* and *σ* were set to be constant as *μ* = 0 and *σ* = 2°. For discrete attractor models in **Figs. 1g-l**, we assumed that the energy function *U*(*θ*_{t}) is proportional to cos(4*θ*_{t}) (**Figs. 1g,j**) so that the drift term *μ*(*θ*_{t}) = sin(4*θ*_{t}) with . In these attractor models, the constant noise in **Figs. 1g-i** is *σ* = 2° and the nonuniform noise in **Figs. 1j-l** is *σ* = 2°(1 − cos(4*θ*_{t})). The biases and standard deviation (SD) of errors were plotted at T = 1, 2, and 3 with 50,000 iterations. For the numerical simulation, dt = 0.01.

#### Bayesian sensory models and extension

In **Figure 2**, we first constructed the sensory inference process, which receives orientation input *θ*, forms a corresponding noisy sensory representation *m* given *θ*, and then infers as an estimate of the input orientation from the encoded representation *m*. This inference is made in a Bayesian manner based on likelihood function *p*(*m*|*θ*) and orientation prior *q*(*θ*).

To construct *p*(*m*|*θ*), we followed the procedure given in ^{9}, and the summary is as follows. We started from the sensory space of where both discriminability and Fisher Information are uniform, and all likelihood functions are homogeneous von Mises functions. And since *J*(*θ*) ∝ (*q*(*θ*))^{2} under the efficient coding condition, the sensory space of and the stimulus space of *θθ* can be mapped by forward and backward mappings *F*(*θ*) and where *F*(*θ*) is the cumulative distribution function of prior *q*(*θθ*). Thus, likelihood functions *p*(*m*|*θ*) can be obtained by taking homogeneous von Mises likelihoods in the sensory space and transforming them back to the stimulus space using *F*^{−1}. To sum up the upper half of the procedural diagram in **Fig. 2a**, the sensory module receives *θ*, encodes it in *m* following *pp*(*m*|*θ*), and decodes using likelihood functions and prior *q*(*θ*).

As an extension to include a memory process, the decoded is passed on to the memory module, where is maintained with the addition of memory noise *ξ*. The output of the memory module, , is fed back to the sensory module as the new input. This completes one iteration of sensory-memory interaction. The whole process is then repeated recursively, resulting in increased biases and standard deviations in the *θ* statistics at subsequent iterations (call them *θ*_{i} for the input of iteration *i*).

For **Figs. 2b-c**, we set the von Mises sensory-space likelihoods to be , with *κ*_{m} = 250. These likelihood functions are transformed by where *q*(*θ*) = 3 + cos (4*θ*). Each internal representation *m* is sampled from *p*(*m*|*θ*), after which *θθ* is estimated as the mean of the posterior *p*(*θ*|*m*)*q*(*θ*). With the parameters chosen above, the inferred samples of after the first iteration have a circular standard deviation of *σ*_{θ} ≈ 1.3° at cardinal orientations. To have comparable memory and sensory noise levels, we set the memory noise *ξ*∼𝒩(0,1.3°). The first three iterations’ output statistics are plotted in **Fig. 2c**, i.e., bias(*θ*_{1}), bias(*θ*_{2}), bias(*θ*_{3}), and SD(*θ*_{1}), SD(*θ*_{2}), SD(*θ*_{3}). The statistics were computed from 10,000 iterations of the simulation. The magnitude of biases and standard deviations vary for different sensory or memory noise levels, while the overall patterns and the increasing temporal trend are unchanged (not shown).

### Firing rate models

For network models, we considered sensory circuits with heterogeneous connections (**Fig. 3**), memory circuits with homogeneous connections (**Fig. 3**) and heterogeneous connections (**Fig. 7**), and sensory-memory interacting circuits (**Figs. 4-6, 8**). In all cases, the activities of neurons are described by their firing rates and synaptic states, denoted by *r* and *s*. For columnar structure encoding orientation stimuli, we indexed the neurons by uniformly assigning them indices for *i* from 1 to *N* where *N* is the number of neurons in each population. For sensory or memory networks alone, the dynamics of neuron *i* are described by the following equations,
where the superscripts *i* and *j* are the neuronal indices, and the subscript *k* is either s or m, representing sensory or memory circuits. For the sensory-memory interacting network, the dynamics are given as
where activities and synaptic inputs are represented in the vector and matrix multiplication form, shown in bold cases. The additional subscripts f and b represent feedforward and backward connections between sensory and memory modules.

In both Eqs. (2) and (3), *s*(*t*) is the low pass filtered *r*(*t*) with synaptic time constant *τ* and with the addition of *ξ* approximating Poisson noise. We modeled *ξ* as the Gaussian process with covariance ⟨*ξ*^{i}(*t*)*ξ*^{i}(*t*′)⟩ = *r*^{i}(*t*)*δ*_{ij}*δ*(*t* − *t*′), following ^{22}. We assumed that the rate dynamics are relatively fast such that *r*(*t*) equals the input current-output rate transfer function *f*. The input current is the sum of external input *I*_{ext} and the synaptic currents from other neurons in the network, which are the postsynaptic states *s*^{j} weighted by synaptic strengths *W*^{ij}. The transfer function *f* has the Naka– Rushton form ^{58} given as
where [·]_{+} denotes the linear rectification function. The transfer functions differ in the sensory and memory modules, denoted as *f*_{s} and *f*_{m}, respectively.

#### Synaptic inputs in network models

Note that for all network models, we only considered excitatory neurons under the assumption that the inhibitory synaptic pathways have relatively fast dynamics. Thus, recurrent connectivity strengths, *W*_{s} and *W*_{m} within sensory and memory modules, reflect summed excitation and inhibition, and thus, can have either positive or negative signs. On the other hand, we assumed that intermodal interactions, *W*_{f} and *W*_{b}, are dominantly excitatory and, thus, can be only positive.

All *W*’s can be defined using neuronal indices of post- and presynaptic neurons as
For *W*_{s} without segregating excitation and inhibition in **Figs. 3-5**, *N* is the population size of sensory module, *N*_{s}, and *J*_{s} is the sum of a constant global inhibition and a short-range excitatory connection as
where *α* > 0 represents the heterogeneity degree of excitatory connectivity, and λ_{E} is the width of local excitatory connections.

When we segregated excitation and inhibition and considered the heterogeneity of inhibitory connection in **Figs. 6** and **8**, Eq. (6) is replaced with
where β > 0 is the degree of heterogeneity of inhibitory connections. Note the signs of modulation change in Eqs. (6) and (7) such that when only excitation is modulated in Eq. (6), the connectivity strengths near the obliques are strong. In contrast, when excitation and inhibition are both modulated in Eq. (7), the connectivity strengths near cardinal orientations are strong.

For the memory module, *N* is the population size of the memory module, *N*_{m} in Eq. (5). Without heterogeneity in **Figs. 3-6** and **8**, *J*_{m} is defined as
In contrast, for the one-module network model in **Fig. 7**, the connectivity of the memory module is heterogeneous, as in the sensory module in Eq. (7), and is defined as
The feedforward and feedback connectivity are similarly defined as
Note the connectivity strength is normalized by the size of the presynaptic population so that the total synaptic current remains the same for different population sizes.

For the external inputs with orientation *θθ, II*_{ext,s} in the sensory module is modeled as
where *ε* ∈ (0,0.5] determines the stimulus tuning of the input, λ_{ext,s} determines the width, and *C* describes the contrast ^{59}.

For the memory network not connected to the sensory module in **Figs. 3** and **7**, we assumed stimulus-specific input as
where *I*_{c,m} is a constant background input. When the memory module receives the inputs from the sensory population in **Figs. 4-6** and **8**, we assumed is constant as *I I*_{c,m}.

#### Analysis of network activities

We used population vector decoding to extract the internal representation of orientation and quantified how such representation deviated from the original stimulus. We also examined how tuning properties and Fisher information change during the delay period.

Note that while we indexed neurons uniformly with ψ_{ii} between 0° and 180°, the maximum of the tuning curve of neuron ψ_{i} can change dynamically and differ from ψ_{i}. We defined the preferred feature (PF) of neuron *i* as the maximum of its tuning curve when the tuning curve reaches a steady state in the presence of external input. For numerical estimation, we set the stimulus-present encoding epoch to 5 seconds to obtain the steady states of tuning curves. The tuning width is given as the full width at half maximum (FWHM) of the tuning curve. To estimate PF and FWHM, we did a cubic spline interpolation to increase the number of sample orientations to 1000. The tuning width index (WI) is given as
To estimate the internal representation of orientation in the network models, denoted as, we utilized the population vector decoder (PVD) ^{60}
where *N* denotes the number of neurons and denotes the PF of neuron *j*. The orientation is always decoded from the memory network tuning curves *r*_{m}(*t*) except for **Fig. 8a**. The estimation bias . Since the bias is typically small enough, we computed the estimation standard deviation (SD) as the SD of bias using linear statistics. The SD index is defined as
The Fisher information (FI) is estimated by assuming that the likelihood function *p*(*r* | *θ*) is Gaussian. Thus, we can estimate the FI of memory neuron *i* with index ψ_{i} based on the empirical mean and variance of the firing rate at time *t* as
and the total FI is the summation of the FI of all memory neurons, given as FI(*t*) = ∑_{i}FI (ψ_{i}, *t*).

#### Drift and diffusivity in network models

Although the modulation breaks the continuity of the ring attractor and forms two discrete attractors at the obliques, there is still a one-dimensional trajectory to which the noise-free dynamics quickly converge. We can linearize the system in the vicinity of this trajectory if the noise is small ^{22}. Note that the dynamics of the synaptic variables in Eq. (3) can be put into the following form
and by linearizing around the stable trajectory , we get
where we have ignored the zeroth- and higher-order terms. The drift velocity *μ*(*θ*) is estimated by projecting the noise-free dynamics along the normalized right eigenvector *u* of *K* with the largest real part of the eigenvalue
The coefficient of diffusion can be obtained in the same way
The noise coefficient is given as . Hence, we have reduced the high-dimensional dynamics to a simple one-dimensional stochastic differential equation as in Eq. (1) as
and the potential *U*(*θ*) is obtained by the relation .

#### Network parameters and simulations

Unless otherwise specified, *N*_{s} = *N*_{m} = 300, *τ* = 10 ms. The connectivity parameters are *J*_{E,s} = 0.35, *J*_{I,s} = 0.6, *J*_{E,m} = 1, *J*_{I,m} = 0.17, *J*_{f} = 0.1, *J*_{b} = 0.25, λ_{E,s} = 0.36*π*, λ_{I,s} = 1.1*π*, λ_{E,m} = 0.2*π*, λ_{I,m} = 0.6*π*, λ_{f} = λ_{b} = 0.17*π*. For the external input, we set *C* = 4, *ε* = 0.2, and λ_{ext,s} = 0.3*π*. For the modulation of the sensory network, unless otherwise specified, we set *α* = 0.04 when only the excitatory plasticity is considered, and *α* = 0.03, β = 0.08 when the inhibitory plasticity is added. As for the modulation of the single-layer memory network, we set *α* = 5 × 10^{−4}, β = 2.4 × 10^{−3}. For the transfer function, *f*_{max} = 100, *T* = 0.1, *q* = 2, *w* = 6 for sensory *f*_{s}, and *f*_{max} = 100, *T* = 0.1, *q* = 1.5, *w* = 6.6 for memory *f*_{m}.

We uniformly sampled 50 cue orientations in [0°, 180°]. The visual cue lasts for 0.5 seconds except for the estimation of the PFs. In the grid parameter search figures, the delay epochs last for 1 s. In **Fig. 3**, we set *α* = 0.07. In **Fig. 5a**, the manifold corresponds to the synaptic variables at 4s into the delay with *α* = 0.05. We uniformly sampled 100 cue orientations for the manifold.

All simulations of ordinary or stochastic differential equations of the network models were done using the Euler method with dt = 1 ms. We checked that similar results hold for smaller dt. Example bias and standard deviation patterns were estimated from 1000 independent realizations. The Fisher information patterns were estimated from 3000 independent realizations. The grid search of maximum bias at *θ* = 22.5° and standard deviation index were computed from 3000 realizations.

## Code availability

All simulations were run in Matlab. The code will be made available upon publication.

## Competing Interests

The authors declare no competing financial interests.

## Acknowledgments

We appreciate X. Wei for sharing the code for Bayesian inference models. J. Y. was supported by the NYU Shanghai Summer Undergraduate Research Program (SURP). S. L. received STI2030-Major Projects, No.2021ZD0203700/2021ZD0203705. H. Z. and S. L. also acknowledge the support of the Shanghai Frontiers Science Center of Artificial Intelligence and Deep Learning and the NYU-ECNU Institute of Brain and Cognitive Science at NYU Shanghai.