Skip to content

Instantly share code, notes, and snippets.

View zengyu714's full-sized avatar

Yu Zeng zengyu714

  • Amazon Web Services
  • Seattle
View GitHub Profile
@zengyu714
zengyu714 / iradon.m
Created May 7, 2017 09:41
Algorithms
%% Direct reconstruction
I = iradon(proj, 1);
subplot(211)
imshow(I)
title('Reconstructed `iradon`');
%% Manually implement
#!/usr/bin/env python
"""Simple HTTP Server With Upload implemented by Python 2.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@zengyu714
zengyu714 / easy_initialize.py
Last active April 19, 2017 16:25
Python gist
class Structure:
# Class variable that specifies expected fields.
_fields= []
def __init__(self, *args):
if len(args) != len(self._fields):
raise TypeError('Expected {} arguments'.format(len(self._fields)))
# Set the arguments.
for name, value in zip(self._fields, args):
@zengyu714
zengyu714 / check_checkpoints.py
Last active April 19, 2017 02:18
TensorFlow utils
from tensorflow.python import pywrap_tensorflow
# Get weights or whatever you want.
# Notice the filename should be full pathname, e.g. './model-7000'
def get_weights(filename):
reader = pywrap_tensorflow.NewCheckpointReader(filename)
var_to_shape_map = reader.get_variable_to_shape_map()
weights = [reader.get_tensor(key) for key in var_to_shape_map if 'weights' in key]
return weights