Skip to content

Instantly share code, notes, and snippets.

@alsrgv
alsrgv / receptive_fields_keras.py
Last active April 1, 2020 20:50
Receptive fields for Keras
import graphviz
import numpy as np
import keras
def gather_layer_stats(layer_dict, layer, r, s):
lr, ls = None, None
if hasattr(layer, 'kernel_size'):
assert layer.kernel_size[0] == layer.kernel_size[1]
assert layer.strides[0] == layer.strides[1]
@alsrgv
alsrgv / tensorflow_mnist_estimator.py
Last active February 8, 2023 10:05
Horovod with Estimator API
# Copyright 2017 Uber Technologies, Inc. All Rights Reserved.
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@alsrgv
alsrgv / test_nccl.c
Created November 19, 2017 17:57
Test NCCL
// Code from http://docs.nvidia.com/deeplearning/sdk/nccl-developer-guide/index.html#onedevprothrd
#define _BSD_SOURCE
#include <stdio.h>
#include "cuda_runtime.h"
#include "nccl.h"
#include "mpi.h"
#include <stdint.h>
#include <stdlib.h>
@alsrgv
alsrgv / keras_mnist_cnn.py
Created September 30, 2017 02:33
Keras with Horovod
from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
import tensorflow as tf
import horovod.tensorflow as hvd