- A simple note for how to start multi-node-training on slurm scheduler with PyTorch.
- Useful especially when scheduler is too busy that you cannot get multiple GPUs allocated, or you need more than 4 GPUs for a single job.
- Requirement: Have to use PyTorch DistributedDataParallel(DDP) for this purpose.
- Warning: might need to re-factor your own code.
- Warning: might be secretly condemned by your colleagues because using too many GPUs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init_weights(m, variance=1.0): | |
def _calculate_fan_in_and_fan_out(tensor): | |
dimensions = tensor.dim() | |
if dimensions < 2: | |
return 1, 1 | |
if dimensions == 2: # Linear | |
fan_in = tensor.size(1) | |
fan_out = tensor.size(0) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Clean and simple Keras implementation of network architectures described in: | |
- (ResNet-50) [Deep Residual Learning for Image Recognition](https://arxiv.org/pdf/1512.03385.pdf). | |
- (ResNeXt-50 32x4d) [Aggregated Residual Transformations for Deep Neural Networks](https://arxiv.org/pdf/1611.05431.pdf). | |
Python 3. | |
""" | |
from keras import layers | |
from keras import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# From https://en.wikipedia.org/wiki/Minkowski–Bouligand_dimension: | |
# | |
# In fractal geometry, the Minkowski–Bouligand dimension, also known as | |
# Minkowski dimension or box-counting dimension, is a way of determining the | |
# fractal dimension of a set S in a Euclidean space Rn, or more generally in a | |
# metric space (X, d). | |
# ----------------------------------------------------------------------------- | |
import scipy.misc | |
import numpy as np |