Skip to content

Commit

Permalink
fix warnings and failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip authored and soumith committed Jul 6, 2020
1 parent 3c032e8 commit 6c8e2ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dcgan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion fast_neural_style/download_saved_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 8 additions & 4 deletions run_python_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

2 changes: 1 addition & 1 deletion word_language_model/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 6c8e2ba

Please sign in to comment.