If you knock, but actually have a gin hand, is it valid to change it after you've knocked?
It is important to note that knocking and going gin are not mutually exclusive. From Pagat:


  Knocking with no unmatched cards at all is called going gin [...]


And Wikipedia:


  Knocking with 0 points of deadwood is known as going Gin or having a Gin hand [...]


If you announced a zero count, then you have gone gin.

If you announced a non-zero count, then you are stuck with the count that you announced and cannot take it back. Your opponent may proceed to lay off cards.

If you did not announce a count, but you have arranged your cards into matched and unmatched groups, then your count is the total of the unmatched cards, and it is too late to change your mind. If you are still in the process of arranging your cards, then your count is not finalized yet, and you can still change your mind.