Skip to content

Commit 6c8e2ba

Browse files
mattipsoumith
authored andcommitted
fix warnings and failures
1 parent 3c032e8 commit 6c8e2ba

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

dcgan/main.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ def forward(self, input):
224224
netD.zero_grad()
225225
real_cpu = data[0].to(device)
226226
batch_size = real_cpu.size(0)
227-
label = torch.full((batch_size,), real_label, device=device)
227+
label = torch.full((batch_size,), real_label,
228+
dtype=real_cpu.dtype, device=device)
228229

229230
output = netD(real_cpu)
230231
errD_real = criterion(output, label)

fast_neural_style/download_saved_models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
try:
1313
from torch.utils.model_zoo import _download_url_to_file
1414
except ImportError:
15-
from torch.hub import _download_url_to_file
15+
try:
16+
from torch.hub import download_url_to_file as _download_url_to_file
17+
except ImportError:
18+
from torch.hub import _download_url_to_file
1619

1720

1821
def unzip(source_filename, dest_dir):

run_python_examples.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function word_language_model() {
148148

149149
function clean() {
150150
cd $BASE_DIR
151+
echo "running clean to remove cruft"
151152
rm -rf dcgan/_cache_lsun_classroom_train_lmdb \
152153
dcgan/fake_samples_epoch_000.png dcgan/lsun/ \
153154
dcgan/_cache_lsunclassroomtrainlmdb \
@@ -194,17 +195,20 @@ if [ "" == "$EXAMPLES" ]; then
194195
else
195196
for i in $(echo $EXAMPLES | sed "s/,/ /g")
196197
do
198+
echo "Starting $i"
197199
$i
200+
echo "Finished $i, status $?"
198201
done
199202
fi
200203

201204
if [ "" == "$ERRORS" ]; then
202-
tput setaf 2
203-
echo "Completed successfully"
205+
[[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput setaf 2
206+
echo "Completed successfully with status $?"
204207
else
205-
tput setaf 1
208+
[[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput setaf 1
206209
echo "Some examples failed:"
207210
printf "$ERRORS"
208211
fi
209212

210-
tput sgr0
213+
[[ "$TERM" != "" ]] && [[ "$TERM" != "dumb" ]] && tput sgr0
214+

word_language_model/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def train():
180180
# `clip_grad_norm` helps prevent the exploding gradient problem in RNNs / LSTMs.
181181
torch.nn.utils.clip_grad_norm_(model.parameters(), args.clip)
182182
for p in model.parameters():
183-
p.data.add_(-lr, p.grad)
183+
p.data.add_(p.grad, alpha=-lr)
184184

185185
total_loss += loss.item()
186186

0 commit comments

Comments
 (0)