Napoleon did think he was going to lose. Otherwise, he would not have been wearing poison around his neck. Like many crazy leaders over the course of history, Napolean was a narcissist, but he wasn't so crazy as to think someone would not get him, or that he could ever lose.
It is well known that Napoleon was a man who craved power and authority. He was one of the most accomplished leaders in terms of battle and it shows with how much land he gained and all his left behind articles. What unfortunately often comes with this type of an attitude however, is a poor attitude towards losing. Napoleon couldn't handle that fact and decided to take his life.
Some leaders and generals due to their larger-than-life egos must have a contingency plan in case their life is suddenly in danger of ending. Some of these plans are more self-centered and vindictive than others. We saw this with Hitler inspiring children to take up arms an defend Germany from invasion while he plotted his suicide. Napoleon was not much different.
Suicide is often planned by spies or leaders as a means to protect against an enemy using their capture as propaganda, giving information, or being used as bargaining power. So, this is not an admission that he thinks he is going to lose. It also serves as an example to his troops that he is fully committed to his cause, even to the point of freely giving his life.