text
stringlengths
1
93.6k
("gitadd2", GitAdd()),
("changelog", UpdateChangelog()),
("readme", UpdateReadme()),
("dist", MakeDist()),
("testpypi", PushToTestPyPI()),
("install", InstallFromTestPyPI()),
("testpkg", TestPackage()),
("remove_venv", RemoveVenv()),
("addrelease", GitAddRelease()),
("pypi", PushToPyPI()),
("tagfinal", GitTagVersion()),
# triggers CI to build with cibw and push to PyPI
("push3", PushToGitHub()),
("ci3", WaitForCI()),
]
context = {}
context["pkgname"] = get_package_name()
context["version"] = get_package_version(context["pkgname"])
skip = True if target else False
for name, step in procedure:
if not name == target and skip:
continue
skip = False
step.run(context)
cprint("\nDone!", color="yellow", style="bright")
if __name__ == "__main__":
target = sys.argv[1] if len(sys.argv) > 1 else None
main(target=target)
# <FILESEP>
from __future__ import division
import math
import os
import time
from config import FLAGS
from util import data_io
import matplotlib.pyplot as plt
from util.custom_ops import *
tf.flags.DEFINE_integer('scale', 4, 'Upsampling scale for super resolution.')
def upsample(input_, up_scale):
with tf.variable_scope("upsample"):
return tf.keras.layers.UpSampling3D(size=(up_scale, up_scale, up_scale), dtype=tf.float32)(input_)
def downsample(input_, down_scale):
with tf.variable_scope("downsample"):
return tf.keras.layers.AveragePooling3D(pool_size=(down_scale, down_scale, down_scale), padding='valid',
dtype=tf.float32)(input_)
def avg_pool(input_, scale):
with tf.variable_scope("avg_pool"):
ls = downsample(input_, scale)
hs = upsample(ls, scale)
return hs
def descriptor(inputs, reuse=False):
with tf.variable_scope('des', reuse=reuse):
# 64
conv1 = conv3d(inputs, 200, kernal=(16, 16, 16), strides=(3, 3, 3), padding="SAME", name="conv1")
conv1 = tf.nn.relu(conv1)
print conv1
conv2 = conv3d(conv1, 100, kernal=(6, 6, 6), strides=(2, 2, 2), padding="SAME", name="conv2")
conv2 = tf.nn.relu(conv2)
print conv2
fc = fully_connected(conv2, 1, name="fc")
print fc
return fc
def langevin_dynamics(syn_arg):
def cond(i, syn):
return tf.less(i, FLAGS.sample_steps)
def body(i, syn):
syn_res = descriptor(syn, reuse=True)
grad = tf.gradients(syn_res, syn, name='grad_des')[0]
y = syn - 0.5 * FLAGS.step_size * FLAGS.step_size * (syn / FLAGS.refsig / FLAGS.refsig - grad)
syn = y - avg_pool(y - syn, FLAGS.scale)
return tf.add(i, 1), syn
with tf.name_scope("langevin_dynamics"):
i = tf.constant(0)
i, syn = tf.while_loop(cond, body, [i, syn_arg])
return syn
def train():
cube_len = FLAGS.cube_len
scale = FLAGS.scale
batch_size = FLAGS.batch_size
output_dir = os.path.join(FLAGS.output_dir, FLAGS.category)
checkpoint_dir = os.path.join(output_dir, 'checkpoints')