Skip to content

Instantly share code, notes, and snippets.

import tensorflow as tf
def add_coord_channels(inputs, with_r=False):
batch_size_tensor = tf.shape(inputs)[0]
x_dim, y_dim = inputs.shape[1].value, inputs.shape[2].value
x_range, y_range = (tf.linspace(-1., 1., d) for d in (x_dim, y_dim))
x_channel = tf.tile(tf.expand_dims(y_range, 0), [x_dim, 1])
y_channel = tf.tile(tf.expand_dims(x_range, 1), [1, y_dim])
# run this with python3
import time
import os
import sys
import re
import json
try:
import psutil
except ImportError:
os.system(sys.executable + " -m pip install psutil")