diff --git a/dcgan/main.py b/dcgan/main.py index 4467e329..96d1feb9 100644 --- a/dcgan/main.py +++ b/dcgan/main.py @@ -224,7 +224,8 @@ def forward(self, input): netD.zero_grad() real_cpu = data[0].to(device) batch_size = real_cpu.size(0) - label = torch.full((batch_size,), real_label, device=device) + label = torch.full((batch_size,), real_label, + dtype=real_cpu.dtype, device=device) output = netD(real_cpu) errD_real = criterion(output, label) diff --git a/fast_neural_style/download_saved_models.py b/fast_neural_style/download_saved_models.py index 71454bc4..691c2c0a 100644 --- a/fast_neural_style/download_saved_models.py +++ b/fast_neural_style/download_saved_models.py @@ -12,7 +12,10 @@ try: from torch.utils.model_zoo import _download_url_to_file except ImportError: - from torch.hub import _download_url_to_file + try: + from torch.hub import download_url_to_file as _download_url_to_file + except ImportError: + from torch.hub import _download_url_to_file def unzip(source_filename, dest_dir): diff --git a/run_python_examples.sh b/run_python_examples.sh index e4de2fad..09f0a1de 100755 --- a/run_python_examples.sh +++ b/run_python_examples.sh @@ -148,6 +148,7 @@ function word_language_model() { function clean() { cd $BASE_DIR + echo "running clean to remove cruft" rm -rf dcgan/_cache_lsun_classroom_train_lmdb \ dcgan/fake_samples_epoch_000.png dcgan/lsun/ \ dcgan/_cache_lsunclassroomtrainlmdb \ @@ -194,17 +195,20 @@ if [ "" == "$EXAMPLES" ]; then else for i in $(echo $EXAMPLES | sed "s/,/ /g") do + echo "Starting $i" $i + echo "Finished $i, status $?" done fi if [ "" == "$ERRORS" ]; then - tput setaf 2 - echo "Completed successfully" + [[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput setaf 2 + echo "Completed successfully with status $?" else - tput setaf 1 + [[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput setaf 1 echo "Some examples failed:" printf "$ERRORS" fi -tput sgr0 +[[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput sgr0 + diff --git a/word_language_model/main.py b/word_language_model/main.py index 61660366..6d88b35c 100644 --- a/word_language_model/main.py +++ b/word_language_model/main.py @@ -180,7 +180,7 @@ def train(): # `clip_grad_norm` helps prevent the exploding gradient problem in RNNs / LSTMs. torch.nn.utils.clip_grad_norm_(model.parameters(), args.clip) for p in model.parameters(): - p.data.add_(-lr, p.grad) + p.data.add_(p.grad, alpha=-lr) total_loss += loss.item()