Due: Sunday 23 September, 23:59 pm
Marks: 15% of final assessment
You will need to run TensorFlow 1.9 for this assignment. The best option is to run it on your own laptop, either in CPU or GPU mode. We expect that most students will be using CPU mode, and the assignment can definitely be completed in this mode. However, the training will run significantly faster if you have an appropriate GPU in your machine, and you manage to configure TensorFlow to make use of it. Instructions for setting up TF-GPU can be found here, and there is a useful forum post here.
Another option is to make use of google colabs. This will allow you to run jupyter notebooks online, but with the ability to hook into a K80 GPU. If you are physically sitting at a CSE lab machine, you can access TensorFlow 1.9 after typing "run64". Note however that this may run quite slowly (because it is using a 64-bit emulator and in CPU mode).
Unzip this archive by typing
unzip Assignment2.zip
You should then see the following files:
data/
Directory containing the training and evaluation datasets. implementation.py
This is a skeleton file for your code. The assignment should be completed by modifying this file. runner.py
This file is a wrapper around implementation.py and contains a large amount of pre-implemented functionality. An unedited version of this file must be used to generate your final model. glove.6B.50d.txt
This is a text file containing the embedding vectors used in this assignment. Word embeddings have been shown to improve the performance of many NLP models by converting words from character arrays to vectors that contain semantic information of the word itself. In this assignment, we use GloVe embeddings, you can read more about them here.
For evaluation, we will run your model against a third dataset "test" that has not been made available to you. If contains additional reviews in the same format. For this reason you should be very careful to avoid overfitting - your model could report 100% training accuracy but completely fail on unseen reviews. There are various ways to prevent this such as judicious use of dropout, splitting the data into a training and validation set, etc.
runner.py
must be used for your final submission,
you are encouraged to make changes to this file during development.
You may want to track additional tensors in tensorboard, or serialize
training data so that the word embedding is not called on each run.
The code to load the review files has already been written for you. However it is essential to perform some level of preprocessing on this text prior to feeding it into your model. Because the GloVe embeddings are all in lowercase, you should convert all reviews to lowercase, and also strip punctuation. You may want to do additional preprocessing by stripping out unnecessary words etc. You should examine any avenue you can think of to reduce superfluous data that you will feed into your model.
Attempt to train a model by running python runner.py train
. This will create local copies of the data and embedding structures for
faster subsequent loading, but will ultimately fail due to implementation.py
being empty.
The goal of this assignment is to add code to implementation.py
in order to train and submit a neural network capable of classifying the sentiment of the provided reviews with
a high level of accuracy.
In this assignment, unlike assignment 1, the network structure is not specified,
and you will be assessed based on the performance of your final classifier.
There are very few constraints on your model - however for this assignment you may NOT make calls to the following parts of the API;
tf.contrib.eager
By extension: do not follow any example that uses the following call at any point in the code. tf.enable_eager_execution()
. tf.keras
tf.estimator
)tf.layers
(this is mostly wrappers for tf.nn
but with nicer parameter structuring)tf.nn
tf.math
are allowed but discouraged - there is probably an easier way to do what you are trying to do.
During testing, we will load your saved network from a TensorFlow checkpoint
(see: the
TensorFlow programmers guide to saved models). To allow
our test code to find the correct path of the graph to connect to, the
following naming requirements must be implemented.
name="input_data"
name="labels"
name="accuracy"
name="loss"
runner.py
in eval mode. If it
succeeds it was able to find all relevant tensors.
Submissions failing to achieve 0.6 accuracy will be assessed by humans and assigned a mark between 0 and 7.
Accuracy Mark 0.6 8 marks 0.65 9 marks 0.7 10 marks 0.75 11 marks 0.8 12 marks 0.85 14 marks 0.9 15 marks
runner.py
checkpoints
directory, and should consist of a
checkpoint
file, plus three files ending in the extentions
.data-00000-of-00001
, .index
and .meta
It also prints loss
values to stdout every 50 iterations. While an unedited version of this file must be used to train your final model,
during development you are encouraged to make modifications. You may wish to display validation accuracy on your
tensorboard plots, for example.
"eval" evaluates the latest model checkpoint present in the local checkpoints
directory and prints the final
accuracy to the console. You should not modify this code.
You may note that in both train and eval mode, the data is first fed through the load_data()
method, which
in turn calls the preprocess(review)
function that you will define. This is to ensure your preprocessing is
consistent across all runs. In otherwords, whatever transformations you apply to the data during training will also
be applied during evaluation and testing.
Further explanation of the functionality of this file appears in comments.
implemention.py
This is where you should implement your solution. This file contains
two functions: preprocess()
, and define_graph()
preprocess(review)
is called whenever a review is loaded from text, prior to
being converted into embedded form. You can do anything here that is manipulation
at a string level, e.g.
define_graph()
is where you
should define your model. You will need to define placeholders, for the input and labels,
Note that the input is not strings of words, but the strings after the embedding lookup
has been applied (i.e. arrays of floats).
To ensure your model is sufficiently general (so as to achieve
the best test accuracy) you should experiment with regularization
techniques such as dropout. This is where you must also provide the
correct names for your placeholders and variables.
There are two variables which you should
experiment with changing. BATCH_SIZE
defines the size of the batches that will
be used to train the model in runner.py
and MAX_WORDS_IN_REVIEW
determines the maximum number for words that
are considered in each sample. Both may have a
significant effect on model performance.
runner.py
, you can view the progress
of your models using the tensorboard logging included in that file.
To view these logs, run the following command from the source directory:
tensorboard --logdir=./tensorboard
http://localhost:6006
runner.py
is running.
For this assignment, tensorboard is an extremely useful tool and you
should endeavor to get it running. A good resource is
here
for more information.
implementation.py
filereport.pdf
A maximum single page document containing a description of the design choices you made and why.
runner.py
give cs9444 hw2 implementation.py report.pdf *.data* *.index *.meta checkpoint
It is your responsibility to ensure the model can be run. The easiest way to check is to ensure running python runner.py eval
functions correctly. Models that cannot be run will receive very low marks. We will not manually review your code and attempt to correct errors.
9444 classrun -check
The submission deadline is Sunday 23 September, 23:59.
15% penalty will be applied to the (maximum) mark
for every 24 hours late after the deadline.
Additional information may be found in the FAQ and will be considered as part of the specification for the project. You should check this page regularly.
If you believe you are getting an error due to a bug in the specification or provided code, you can post to the forums on the course Web page. Please only post queries after you have made a reasonable effort to resolve the problem yourself. If you have a generic request for help you should attend one of the lab consultation sessions during the week.
This assignment will be marked on functionality in the first instance. You should always adhere to good coding practices and style. In general, a program that attempts a substantial part of the job but does that part correctly will receive more marks than one attempting to do the entire job but with many errors.
Your program must be entirely your own work. Plagiarism detection software will be used to compare all submissions pairwise and serious penalties will be applied, particularly in the case of repeat offences.
DO NOT COPY FROM OTHERS; DO NOT ALLOW ANYONE TO SEE YOUR CODE
Please refer to the UNSW Policy on Academic Integrity and Plagiarism if you require further clarification on this matter.
Good luck!