Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nkcr/ec2509f8e8737d0969e5a4528c637372 to your computer and use it in GitHub Desktop.
Save nkcr/ec2509f8e8737d0969e5a4528c637372 to your computer and use it in GitHub Desktop.
Implementing a CNN for Text Classification.ipynb
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nkcr
Copy link
Author

nkcr commented May 24, 2018

This is the source code used to compare word2vec initialization versus not.

In the training section, comment or not the following block of code to have word2vec initialization or not:

      # 
      # Use of pre-trained word2vec
      #
      initW = None
      print("Load word2vec at {}".format(FLAGS.pre_trained_w2v))
      initW = load_pre_tained_word2vec(voc_dict, FLAGS.pre_trained_w2v)
      sess.run(cnn.W.assign(initW))

The experiments show that using word2vec initialization or not gives the same result.

The following shows accuracy over epochs on 3 runs. One with random initialization of embedding, another with word2vec initialization and another with word2vec initialization but without further learning of embedding parameters:

capture d ecran 2018-05-28 a 13 06 26

The one which grows less fast is with the random initialization.

Here is the loss and corresponding colors:

capture d ecran 2018-05-28 a 13 10 55
capture d ecran 2018-05-28 a 13 11 08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment