Skip to content
This repository has been archived by the owner on Nov 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #14 from starcolon/adaptive-weight
Browse files Browse the repository at this point in the history
Adaptive weight
  • Loading branch information
Tao (StarColon) authored Apr 25, 2017
2 parents 59b439f + 68259b6 commit e4efec8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def train(samples):
# NOTE: Automatically continue training the existing model
# Otherwise, starts a new model if there is no model file found.
cnn = train_model(
path_model if os.path.isfile(path_model + '0.npz') else None,
path_model if os.path.isfile(path_model) else None,
trainsetX,
trainsetY,
validsetX,
Expand Down
3 changes: 2 additions & 1 deletion model/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import lasagne
import pickle
from lasagne import layers
from lasagne.updates import adagrad, adadelta
from lasagne.updates import adagrad, adadelta, apply_momentum
from lasagne.objectives import *
from nolearn.lasagne import NeuralNet
from nolearn.lasagne import visualize
Expand Down Expand Up @@ -80,6 +80,7 @@ def train(self,X,y,X_,y_,batch_size=1000,num_epochs=100,learn_rate=[0.001,0.001,
loss = [T.sqrt(T.mean((output[i] - outputy[i])**2)) for i in range(len(self.nets))]
params = [layers.get_all_params(n) for n in self.nets]
update = [adadelta(loss[i], params[i]) for i in range(len(self.nets))]
update = [apply_momentum(update[i], params[i], momentum=0.8) for i in range(len(self.nets))]

print(colored('...Preparing training functions','green'))
models = [theano.function(
Expand Down
4 changes: 2 additions & 2 deletions model/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
def train_model(path, X, y, X_, y_, image_dim, final_vec_dim, epoch, batch_size):

# Create a new CNN
if path is None:
print(colored('Creating a new CNN.','green'))
if path is None or not os.path.isfile(path + '0'):
print(colored('Creating a new CNN.','cyan'))
cnn = CNN(image_dim, final_vec_dim)
else:
print(colored('Loading model from : {0}'.format(path),'green'))
Expand Down
2 changes: 1 addition & 1 deletion setup-ec2-and-run
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mkdir -p data/out
mkdir -p data/unfiltered
sudo pip3 install -r requirements.txt
cd data/
wget http://starcolon.com/data/train.tar.gz
wget http://starcolon.com/data/dataset.tar.gz
tar -xvf train.tar.gz
rm raw/._*
rm train.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion vision/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .filters import *

def get_sample_dim(): # n
return 128 # total vector dimensionality : n^2 * 3
return 640 # total vector dimensionality : n^2 * 3

def generate_filtered(sample,max_combination=5):
# Make transformation functions
Expand Down

0 comments on commit e4efec8

Please sign in to comment.