That would be a really stupid thing to do. A judge who accepts such an argument will also have no problem with sending you to jail forever. Because, you see, if your actions are pre-determined then so are his.
There is the defence of necessity. For example is someone threatens to kill you unless you do something, then you wont be punished for that something you did.