Ben Chuanlong Du's Blog

It is never too late to learn.

Date and Time in Python pandas

Date/time utilities in the pandas module are more flexible/powerful than that in the datetime module. It is suggested that you use date/time utilities in the pandas module when you use DataFrame/Series in the pandas module.

  1. pandas.to_datetime works on an iterable object, handles missing values and nano seconds.

  2. pandas.Series.dt.strftime

The Python Quit Unexpectedly Error

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

If you are using Homebrew, you can reinstall a corrupted Python environment like this:

brew uninstall --ignore-dependencies --force python python@2 unset PYTHONPATH brew install python python@2 I had another …

Gradient Clipping in PyTorch

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

optimizer.zero_grad()        
output = model(data)
loss = F.nll_loss(output, target)
loss.backward()
torch.nn.utils.clip_grad_norm_(model.parameters(), args.clip)
optimizer.step()
  1. Use torch.nn.utils.clips_grad_norm_ (which is in-place) instead …

Tensor Transformations in TorchVision

Comments

  1. Transformations in torchvision.transforms work on images, tensors (representing images) and possibly on numpy arrays (representing images). However, a transformation (e.g., ToTensor) might work differently on different input types. So you'd be clear about what exactly a transformation function does. A good practice is to always convert your non-tensor input data to tensors using the transformation ToTensor

Public Cloud Offering GPU Support

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

https://lambdalabs.com/

https://www.floydhub.com/

https://colab.research.google.com/notebooks/intro.ipynb#recent=true

Amazon AWS

Below is a list of instances that have 1 GPU on Amazon …