예제 #1
0
#TODO: support concatenating multiple datasets
print 'script launched'

try:
    from ia3n.util.mem import MemoryMonitor
    mem = MemoryMonitor()
except ImportError:
    mem = None
if mem:
    print 'memory usage on launch: '+str(mem.usage())
import numpy as np
from optparse import OptionParser
from galatea.s3c.hacky_multiclass_logistic import HackyMulticlassLogistic
from galatea.s3c.feature_loading import get_features
from pylearn2.utils import serial
from pylearn2.datasets.cifar10 import CIFAR10
from pylearn2.datasets.cifar100 import CIFAR100
import gc
gc.collect()
if mem:
    print 'memory usage after imports'+str(mem.usage())

def train_model(fold_train_X, fold_train_y, C):
    fold_train_X = np.cast['float64'](fold_train_X)

    model = HackyMulticlassLogistic(C).fit(fold_train_X, fold_train_y)
    gc.collect()

    return model

def get_labels_and_fold_indices(cifar10, cifar100, stl10):
예제 #2
0
#TODO: support concatenating multiple datasets
try:
    from ia3n.util.mem import MemoryMonitor
    mem = MemoryMonitor()
except ImportError:
    mem = None
if mem:
    print 'memory usage on launch: '+str(mem.usage())
import numpy as np
import warnings
from optparse import OptionParser
try:
    from sklearn.svm import LinearSVC, SVC
except ImportError:
    from scikits.learn.svm import LinearSVC, SVC
from pylearn2.datasets.tl_challenge import TL_Challenge
from galatea.s3c.feature_loading import get_features
from pylearn2.utils import serial
import gc
gc.collect()
if mem:
    print 'memory usage after imports'+str(mem.usage())

def get_svm_type(C, one_against_many):
    if one_against_many:
        svm_type = LinearSVC(C=C)
    else:
        svm_type =  SVC(kernel='linear',C=C)
    return svm_type

예제 #3
0
#TODO: support concatenating multiple datasets
try:
    from ia3n.util.mem import MemoryMonitor
    mem = MemoryMonitor()
except ImportError:
    mem = None
import numpy as np
import warnings
from optparse import OptionParser
try:
    from sklearn.svm import LinearSVC, SVC
except ImportError:
    from scikits.learn.svm import LinearSVC, SVC
from galatea.s3c.feature_loading import get_features
from pylearn2.utils import serial
from pylearn2.datasets.cifar10 import CIFAR10
import gc


rng = np.random.RandomState([1,2,3])


def get_svm_type(C):
    svm_type = LinearSVC(C=C)
    return svm_type


def subtrain(fold_train_X, fold_train_y, C):
    assert str(fold_train_X.dtype) == 'float32'

    #assert fold_train_X.flags.c_contiguous