State television broadcast images of Castro sitting at a desk and conversing with students and teachers at the school, named after Vilma Espin, who died in 2007 aged 77.
"I'm sure that on a day like today, Vilma would be happy," said the leader of Cuba's 1959 revolution.
"Everybody who dies fighting for the revolution leaves their energy on the way, they leave their effort and struggle," Castro said.
Castro, whose 90th birthday is in August, handed over the presidency of Cuba in 2008 to his younger brother Raul Castro after a serious illness. He often meets foreign dignitaries at his home and writes occasional newspaper columns, but is rarely seen in public.
Raul Castro is the widower of Espin, who left a comfortable life to join the brothers fighting in the Cuban mountains against a pro-U.S. regime. She became one of the most powerful women in Cuba's political leadership.