
8 The Brain’s GPS: Place Cells, Grid Cells, and Cognitive Maps
Learning Objectives By the end of this chapter, you will be able to:
- Describe the key neural components of the brain’s spatial navigation system.
- Explain the distinct roles of place cells, grid cells, and head direction cells.
- Connect the brain’s method of creating “cognitive maps” to modern AI concepts like Graph Neural Networks and Transformers.
- Analyze how animals and humans represent and navigate their environments.
- Implement and visualize simple computational models of place and grid cells in Python.
8.2 3.1 The Hippocampus: Your Brain’s Memory Architect
The hippocampal formation is a seahorse-shaped structure deep in the brain, essential for both memory and navigation. Its primary job is to bind together different aspects of an experience—what happened, where it happened, and when—into a coherent memory. Its internal wiring, refined over millions of years of evolution, is perfectly suited for creating and reading spatial maps.
The main information pathway flows through key subregions: - Entorhinal Cortex (EC): The main gateway, acting as a sophisticated interface between the hippocampus and the neocortex. This is where the grid cells reside. - Dentate Gyrus (DG): Performs “pattern separation,” ensuring that memories for similar-looking places are stored distinctly. - Hippocampus Proper (CA3 & CA1): The core of memory indexing. CA3 is skilled at “pattern completion” (recalling a whole memory from a partial cue), while CA1 is the final output stage.
This structured, layered processing pipeline is a recurring theme in both neuroscience and AI, allowing for the gradual construction of complex representations from simple inputs.
8.3 3.2 Place Cells: The Pins on Your Mental Map
Discovered by John O’Keefe in 1971, place cells are the simplest component of the brain’s GPS to understand. They are neurons in the hippocampus that fire only when an animal is in a specific location in its environment.
Human Analogy: The Smart Pinboard Imagine you’re exploring a new city. Your brain’s place cells act like smart, digital pins on a mental pinboard: - You enter a noteworthy cafe, and a specific “cafe” neuron fires. Pin #1 is placed. - You walk to a park, and a different “park” neuron becomes active. Pin #2 is placed. - Each pin is silent until you return to its specific location. - The collection of all these pins forms a map of the city.
This isn’t just a map of locations, but a map of meaningful locations. The system is dynamic: if you discover a new favorite spot, a new pin can be added.
Key Properties of Place Cells:
- Spatially Specific: A place cell has a “place field”—its preferred firing zone.
- Dynamic Remapping: When you enter a new environment (e.g., a different hotel), the place cells instantly create a new, independent map. The “lobby” cell from your hotel in Paris is different from the “lobby” cell in your hotel in Tokyo.
- Experience-Driven: Place fields are shaped by experience and attention. A location you care about will be represented more robustly.
- Sparse and Efficient: At any given moment, only a small fraction of place cells are active. This is a highly efficient way to encode location, a principle known as sparse coding that is highly valued in AI for its efficiency and robustness.
Figure 3.1: Comparison of place cell and grid cell activity patterns. Place cells fire in specific, unique locations, while grid cells fire in a repeating hexagonal pattern across the entire space.
8.4 3.3 Grid Cells: The Brain’s Universal Coordinate System
If place cells are the pins, what is the pinboard made of? Discovered by Edvard and May-Britt Moser in 2005 (a discovery that earned them a Nobel Prize), grid cells provide the underlying coordinate system. These neurons, found in the entorhinal cortex, fire in a breathtakingly regular pattern.
A single grid cell doesn’t just fire in one spot; it fires in multiple locations that form a hexagonal, crystal-like lattice across the entire environment.
The Genius of the Hexagonal Grid:
- Geometric Efficiency: A hexagonal grid is the most efficient way to tile a 2D plane. It provides the best coverage with the fewest resources—a beautiful example of natural optimization.
- Multi-Scale Representation: Grid cells are organized into modules with different scales (grid spacing). Some modules have a fine-grained grid for high-precision local maps, while others have a coarse grid for large-scale navigation.
- A Universal Ruler: Unlike place cells, the grid pattern is consistent across different environments. It’s a universal metric that the brain can apply to any new space it encounters.
Human Analogy: The Ghostly City Grid Imagine every new place you visit—a forest, an open field, a shopping mall—has an invisible, hexagonal grid of “hotspots” overlaid on it. - A single grid cell in your brain is tuned to this grid. It fires every time you step on one of its hotspots. - Other grid cells are tuned to different grids, either shifted in space or scaled up or down. - By combining the signals from these different grid modules, your brain can pinpoint your exact location with incredible precision. It’s like using multiple GPS satellites with different resolutions to triangulate your position.
8.5 3.4 From Cells to Cognitive Maps: The AI Connection
Place cells and grid cells don’t work alone. They are part of a larger circuit that includes Head Direction cells (an internal compass) and Border cells (which fire near walls and edges). Together, they create a rich, flexible cognitive map.
This is where the parallels to modern AI become incredibly exciting.
The Cognitive Map as a Graph Neural Network (GNN)
A cognitive map is fundamentally a graph. The places are the nodes, and the paths between them are the edges. - Place Cells as Nodes: Each place cell represents a node in the graph (e.g., “the cafe,” “the library”). - Learned Connections as Edges: The strength of the connection between two place cells represents the ease of travel between them. - GNNs for Navigation: This is precisely the structure a GNN is designed to work with. An AI agent could use a GNN to reason about a spatial environment: “If I am at the cafe (Node A), what is the shortest path to the park (Node C)?” The GNN could propagate information through the graph to find the optimal route, mirroring how the brain plans trajectories.
Path Integration and Attention
The brain also performs path integration (or “dead reckoning”), updating its position based on self-motion cues. Grid cells are thought to be the engine for this. However, this process accumulates errors over time.
- Landmarks as Anchors: To correct these errors, the brain uses landmarks (visual cues, sounds).
- The Role of Attention: How does the brain know which landmarks are important? This is a job for an attention mechanism, similar to that in a Transformer. When you are lost, your brain doesn’t pay attention to every single tree; it selectively focuses on the most informative cues—a distinctive building, a river, a mountain peak. A Transformer’s attention heads perform a similar function, weighing the importance of different pieces of information in a sequence. An AI navigation agent could use attention to dynamically decide which sensory inputs are most useful for re-localizing itself.
8.6 3.5 Code Lab: Modeling the Brain’s GPS
Let’s build simple models to visualize how these cells work. The code is designed for clarity, not performance.
Modeling Place Cells
Here, we’ll create a population of place cells with Gaussian firing fields randomly scattered across an environment.
Modeling a Grid Cell
Next, we’ll model a single grid cell. The hexagonal pattern is created by the interference of three plane waves, a beautifully simple way to generate a complex pattern.

Modeling Path Integration
Finally, a simple simulation of path integration (dead reckoning) shows how small errors in estimating velocity can accumulate over time, causing the estimated path to drift away from the true path. This highlights why external landmarks are crucial for correcting the internal GPS.

8.7 3.6 Key Takeaways
- The brain’s navigation system is not a single component but a distributed circuit of specialized cells.
- It combines specific, context-dependent representations (place cells) with a universal, metric coordinate system (grid cells).
- The principles it uses—sparse coding, geometric efficiency, multi-scale analysis—are hallmarks of powerful and robust computational systems.
- The brain’s cognitive map can be viewed as a graph, making it a biological precursor to GNNs.
- The need to correct for drift using landmarks highlights the importance of attention, a key component of Transformer architectures.
- Studying the brain’s solutions for navigation continues to provide a rich source of inspiration for building more capable and intelligent AI agents.
Chapter Summary In this chapter, we navigated the brain’s internal GPS, uncovering the neural machinery that allows us to find our way.
- We explored the hippocampal formation, the brain’s hub for spatial memory.
- We met the key players: place cells (the “you are here” markers), grid cells (the geometric coordinate system), head direction cells (the internal compass), and border cells (the wall detectors).
- We drew deep connections between these biological systems and modern AI, framing the cognitive map as a Graph Neural Network and the use of landmarks as a form of attention.
- Through code labs, we visualized how these cells represent space and how path integration works, complete with its inherent drift.
This journey reveals a profound truth: the challenges of navigation have driven the evolution of sophisticated computational principles in the brain, many of which we are now rediscovering in our quest to build artificial intelligence.
8.8 3.6 Exercises
Conceptual Questions
Explain the functional difference between place cells and grid cells. How do these two cell types work together to create a cognitive map? What unique computational advantage does each type provide?
Compare and contrast remapping in place cells versus the stability of grid cells. When an animal enters a new environment, place cells undergo “remapping” while grid cells maintain their hexagonal structure. What does this tell us about the computational roles of these two systems?
Describe the parallel between cognitive maps and Graph Neural Networks (GNNs). How are place cells analogous to nodes and learned connections analogous to edges? What graph-based operations might the brain perform for navigation?
Explain the concept of sparse coding in the context of place cells. Why is sparse coding computationally efficient? How might this principle be applied in artificial neural networks?
Computational Problems
- Implement a simple place cell population. Write Python code to:
- Create 20 place cells with randomly distributed place fields in a 10x10 environment
- Simulate an agent moving along a trajectory through this environment
- Plot which place cells are active at each point along the trajectory
- Calculate the “population vector” that could be used to decode the animal’s position
- Analyze grid cell spacing and resolution. Using the grid cell code from the chapter:
- Generate grid patterns with spacings of 10, 20, 30, and 40 units
- For a 100x100 environment, calculate how many unique “grid states” each spacing provides
- Discuss the trade-off between spatial resolution and coverage
- Model path integration error accumulation. Extend the path integration simulation to:
- Add a landmark “reset” mechanism that corrects position every N steps
- Compare error accumulation with and without landmark corrections
- Determine the optimal frequency of landmark corrections to minimize computational cost while maintaining accuracy
- Create a simple GNN for spatial navigation. Implement a basic graph where:
- Nodes represent locations (rooms in a building)
- Edges represent connections (doorways)
- Use a simple message-passing algorithm to find the shortest path between two rooms
- Compare this to how the hippocampus might perform similar computations
Discussion Questions
- Real-world applications of spatial navigation principles. Discuss how the brain’s GPS system could inspire improvements in:
- Autonomous robot navigation in dynamic environments
- Indoor positioning systems where GPS is unavailable
- Virtual reality applications
- Multi-agent coordination systems
- The role of attention in spatial navigation. The chapter mentions that attention mechanisms in Transformers are analogous to how the brain selects important landmarks. Discuss:
- How might the brain implement an attention mechanism for landmark selection?
- What makes a landmark “salient” or worth attending to?
- How could this inspire better attention mechanisms in AI navigation systems?
8.9 3.7 References
O’Keefe, J., & Dostrovsky, J. (1971). The hippocampus as a spatial map. Brain Research, 34(1), 171-175.
Hafting, T., Fyhn, M., Molden, S., Moser, M. B., & Moser, E. I. (2005). Microstructure of a spatial map in the entorhinal cortex. Nature, 436(7052), 801-806.
Moser, E. I., Kropff, E., & Moser, M. B. (2008). Place cells, grid cells, and the brain’s spatial representation system. Annual Review of Neuroscience, 31, 69-89.
McNaughton, B. L., Battaglia, F. P., Jensen, O., Moser, E. I., & Moser, M. B. (2006). Path integration and the neural basis of the ‘cognitive map’. Nature Reviews Neuroscience, 7(8), 663-678.
Rowland, D. C., Roudi, Y., Moser, M. B., & Moser, E. I. (2016). Ten years of grid cells. Annual Review of Neuroscience, 39, 19-40.
Banino, A., Barry, C., Uria, B., Blundell, C., Lillicrap, T., Mirowski, P., et al. (2018). Vector-based navigation using grid-like representations in artificial agents. Nature, 557(7705), 429-433.
Stachenfeld, K. L., Botvinick, M. M., & Gershman, S. J. (2017). The hippocampus as a predictive map. Nature Neuroscience, 20(11), 1643-1653.
Whittington, J. C., Muller, T. H., Mark, S., Chen, G., Barry, C., Burgess, N., & Behrens, T. E. (2020). The Tolman-Eichenbaum machine: Unifying space and relational memory through generalization in the hippocampal formation. Cell, 183(5), 1249-1263.
Knierim, J. J., & Zhang, K. (2012). Attractor dynamics of spatially correlated neural activity in the limbic system. Annual Review of Neuroscience, 35, 267-285.
Edvardsen, V., Bicanski, A., & Burgess, N. (2020). Navigating with grid and place cells in cluttered environments. Hippocampus, 30(3), 220-232.
Burgess, N., Barry, C., & O’Keefe, J. (2007). An oscillatory interference model of grid cell firing. Hippocampus, 17(9), 801-812.
Cueva, C. J., & Wei, X. X. (2018). Emergence of grid-like representations by training recurrent neural networks to perform spatial localization. arXiv preprint arXiv:1803.07770.