Oh, finally I got it!
The problem was, that there were some redundant columns in the inputs. I have not seen them, because I have a huge amount of data.
It seems that the training process ignores these columns, but I could not see which of them.
If I get rid of them before the training, than there are no deviations in size of the input and size of the weight matrix.