Skip to content

Commit ec3e247

Browse files
imj@uoguelph.calebek
authored andcommitted
update
1 parent 3e72632 commit ec3e247

7 files changed

+24
-14
lines changed

Diff for: autoencoder.py

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def cost(self, X):
7373
reconImage = self.decoder(robj1)[:,:,0].flatten()
7474
return T.sum((X-reconImage)*(X-reconImage))
7575

76+
7677
#Should be this when we have multiple inputs NxD
7778
#return T.mean(0.5* T.sum((X-reconImage)*(X-reconImage),axis=1))
7879

Diff for: optimize.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def optimize(self, train_data, lr):
126126
update_vars.append((var, var-lr*gvar))
127127

128128
opt = theano.function([], cost, updates=update_vars, givens={X: train_data[0]})
129-
130-
get_grad = theano.function([] , grads[-2], givens={X:train_data[0]})
129+
get_grad = theano.function([], grads[-2], givens={X:train_data[0]})
131130
get_gradb = theano.function([], grads[-1], givens={X:train_data[0]})
132131
return opt, get_grad, get_gradb
133132

@@ -167,7 +166,7 @@ def optimizeADAM(self, train_data, lr, \
167166
opt = theano.function([], cost, updates=updates,
168167
givens={X: train_data[0]})
169168

170-
get_grad = theano.function([], grads[-2], givens={X:train_data[0]})
169+
get_grad = theano.function([], grads[-2], givens={X:train_data[0]})
171170
get_gradb = theano.function([], grads[-1], givens={X:train_data[0]})
172171
return opt, get_grad, get_gradb
173172

Diff for: optimize_brightness.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import os
22
import numpy as np
33
from optimize import GDOptimizer
4+
from scene import *
5+
from shader import *
6+
from shape import *
7+
from transform import *
48
import theano
59
from util import *
610

711
### Hyper-parameters ###
8-
OptmizeFlag=False
12+
OptmizeFlag=True
913
#-----------------------
1014

1115

@@ -52,3 +56,5 @@
5256
print 'Step', i+1
5357
print train()
5458
drawWithMarkers('output/%d.png' % (i+1,), render_fn())
59+
60+

Diff for: scene.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def build(self, antialias_samples=4):
2121
image = T.alloc(0., self.camera.x_dims, self.camera.y_dims, 3)
2222

2323
#Anti-Aliasing
24-
sampleDist_x = np.random.random((self.camera.x_dims, self.camera.y_dims,antialias_samples))
25-
sampleDist_y = np.random.random((self.camera.x_dims, self.camera.y_dims,antialias_samples))
24+
sampleDist_x = np.asarray(np.random.random((self.camera.x_dims, self.camera.y_dims,antialias_samples)),dtype=theano.config.floatX)
25+
sampleDist_y = np.asarray(np.random.random((self.camera.x_dims, self.camera.y_dims,antialias_samples)),dtype=theano.config.floatX)
2626

2727
for sample in xrange(antialias_samples): #TODO USE SCAN
2828

@@ -65,10 +65,11 @@ def make_rays(self, x_dims, y_dims, sampleDist_x=None, sampleDist_y=None):
6565

6666
rays = np.dstack(np.meshgrid(np.linspace(0.5, -0.5, y_dims),
6767
np.linspace(-0.5, 0.5, x_dims), indexing='ij'))
68-
rays = np.dstack([rays, np.ones([y_dims, x_dims])])
68+
rays = np.dstack([rays, np.ones([y_dims, x_dims], dtype='float32')])
6969
rays = np.divide(rays, np.linalg.norm(rays, axis=2).reshape(
7070
y_dims, x_dims, 1).repeat(3, 2))
7171

72+
rays = np.asarray(rays, dtype=theano.config.floatX)
7273
if sampleDist_x is not None: rays[:,:,0] = rays[:,:,0] + sampleDist_x / x_dims
7374
if sampleDist_y is not None: rays[:,:,1] = rays[:,:,1] + sampleDist_y / y_dims
7475
return RayField(T.as_tensor_variable([0., 0., 0.]), T.as_tensor_variable(rays))

Diff for: test_1ball.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ def scene(center1):
4747

4848
center = get_center()
4949
print '...Initial center1 (%g,%g,%g)' % (center[0], center[1], center[2])
50+
print recon.sum()
51+
52+
ggg =get_grad()
53+
gbb =get_gradb()
54+
import pdb; pdb.set_trace()
55+
5056
n=0;
5157
while (n<3):
5258
n+=1
53-
ggg =get_grad()
54-
gbb =get_gradb()
55-
import pdb; pdb.set_trace()
59+
5660
train_loss = train_ae()
5761
center = get_center()
5862
print '...Epoch %d Train loss %g, Center (%g, %g, %g)' \

Diff for: transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __call__(self, x):
5555

5656
def identity():
5757
"""Returns the identity transform"""
58-
return Transform(np.eye(4, 4), np.eye(4, 4))
58+
return Transform(np.asarray(np.eye(4, 4),dtype=theano.config.floatX) , np.asarray(np.eye(4, 4), dtype=theano.config.floatX))
5959

6060
def translate(x):
6161
"""Returns a transform to represent a translation"""

Diff for: util.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ def initialize_weight(n_vis, n_hid, W_name, numpy_rng, rng_dist):
1313
W = numpy_rng.uniform(low=-np.sqrt(6. / (n_vis + n_hid)),\
1414
high=np.sqrt(6. / (n_vis + n_hid)),
1515
size=(n_vis, n_hid)).astype(theano.config.floatX)
16-
#if 'exp' in rng_dist :
17-
# W = np.exp(-W)
1816
elif rng_dist == 'normal':
1917
W = 0.01 * numpy_rng.normal(size=(n_vis, n_hid)).astype(theano.config.floatX)
2018

21-
return theano.shared(value = W, name=W_name)
19+
return theano.shared(value = W, name=W_name, borrow=True)
2220

2321

2422

@@ -52,3 +50,4 @@ def drawWithMarkers(fname, im):
5250

5351
def draw(fname, im):
5452
imsave(fname, im)
53+

0 commit comments

Comments
 (0)