Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroFerreiradaCosta committed Aug 20, 2020
2 parents 255ba5f + 3404848 commit c93e73e
Show file tree
Hide file tree
Showing 18 changed files with 4,419 additions and 3,098 deletions.
5 changes: 3 additions & 2 deletions 1 - Autoregressive Models - PixelCNN/pixelCNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def train_step(batch_x, batch_y):
with tf.GradientTape() as ae_tape:
logits = pixelcnn(batch_x, training=True)

loss = compute_loss(tf.one_hot(batch_y, q_levels), logits)
loss = compute_loss(tf.squeeze(tf.one_hot(batch_y, q_levels)), logits)

gradients = ae_tape.gradient(loss, pixelcnn.trainable_variables)
gradients, _ = tf.clip_by_global_norm(gradients, 1.0)
Expand All @@ -218,14 +218,15 @@ def train_step(batch_x, batch_y):
loss = train_step(batch_x, batch_y)

progbar.add(1, values=[('loss', loss)])

# ------------------------------------------------------------------------------------
# Test set performance
test_loss = []
for batch_x, batch_y in test_dataset:
logits = pixelcnn(batch_x, training=False)

# Calculate cross-entropy (= negative log-likelihood)
loss = compute_loss(tf.one_hot(batch_y, q_levels), logits)
loss = compute_loss(tf.squeeze(tf.one_hot(batch_y, q_levels)), logits)

test_loss.append(loss)
print('nll : {:} nats'.format(np.array(test_loss).mean()))
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ Clone the git repository :
git clone https://github.com/Mind-the-Pineapple/Autoregressive-models.git

Python 3 with [TensorFlow 2.0+](https://www.tensorflow.org/) are the primary requirements.
Install virtualenv and creat a new virtual environment:
Install virtualenv and create a new virtual environment:

sudo apt-get install -y python3-venv
python3 -m venv ./venv
sudo apt update
sudo apt install python3-dev python3-pip
sudo pip3 install -U virtualenv # system-wide install
virtualenv --system-site-packages -p python3 ./venv

Then, install requirements

source venv/bin/activate
source ./venv/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt

<h1 align="center"> 1. Autoregressive Models — PixelCNN </h1>
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit c93e73e

Please sign in to comment.