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
# 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") |
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
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]) |