Get out - find someone else. It's not your job to fix him and if you can't predict his mood and reactions, how can you have a real relationship with him? Please, don't waste your time - life is too short. Find someone who appreciates you and aceepts you.
You need to stoke the fires, if show lack of interest he will mentally say "ok then, forget it" and shut down himself, either that or he is just fickle and perhaps has a low attention span, or maybe he wants sex but then something about you turns him off. I can only guess, ask him.
his thermostat is not workin, get him fixed
i wouldn't get too attached and i'd go have your own fun without him. his behavior is bad news-- it's not fun to ride the love roller-coaster. you're better off without him.
I've been where you are. Men who blow hot and cold do not make good boyfriends. Feeling confused by your boyfriend's behaviour is a huge alarm bell - make your way to the nearest exit.
He loves you.