Imagine an agent that interacts with an environment over time. Why is having memory important for this agent?
Think about how remembering past events can help in making choices.
Memory helps agents by storing past experiences, which they can use to improve decisions in new situations. Without memory, agents only react to the current input without learning from history.
Consider two simple agents processing a sequence of inputs. One agent remembers the sum of all previous inputs; the other does not. What is the output of the memory agent after processing inputs [1, 2, 3]?
inputs = [1, 2, 3] class MemoryAgent: def __init__(self): self.total = 0 def process(self, x): self.total += x return self.total agent = MemoryAgent() outputs = [agent.process(x) for x in inputs] print(outputs)
Think about how the total changes after each input.
The memory agent keeps adding each input to a running total. After input 1, total is 1; after input 2, total is 3; after input 3, total is 6.
You want to build an agent that remembers long sequences of past events to make decisions. Which model architecture is best suited for this task?
Consider which models can handle sequences and remember past inputs.
RNNs and LSTMs are designed to process sequences and keep memory of past inputs, making them suitable for agents needing memory. Feedforward networks and CNNs do not have built-in memory, and KNN does not handle sequences inherently.
You train two agents on a task requiring remembering past states. Agent A has memory; Agent B does not. Which metric difference best shows the benefit of memory?
Think about how memory helps with tasks involving sequences.
Memory helps agents understand context over time, improving accuracy and reducing errors (loss) on tasks that depend on past information.
An agent is supposed to update its memory by adding the current input to the stored state. However, the memory never changes from zero. What is the likely bug in this code?
class Agent: def __init__(self): self.memory = 0 def update(self, x): self.memory + x agent = Agent() agent.update(5) print(agent.memory)
Check if the memory variable changes after calling update.
The line 'self.memory + x' computes the sum but does not store it back. It should be 'self.memory += x' or 'self.memory = self.memory + x' to update the memory.