The 32-year-old suffered a straight-sets defeat to the 31-year-old Spaniard, going down 7-6(3) 6-3 6-4 on Monday.
"I've definitely got to go back to work and come back stronger, get rid of this loss now as quick as I can, forget about it, because that's not how I want to play from here on," BBC Sport quotes him as saying.
"I want to play better. I know I can. I showed it the last few weeks, that there is that level, so today was pretty frustrating."
This is the second time in a row that Federer has failed to progress to the quarter-finals of a Grand Slam.