def get_data_loader(name, train=True): """Get data loader by name.""" if name == "MNIST": return get_mnist(train) elif name == "USPS": return get_usps(train) elif name == "SVHN": return get_svhn(train)
def get_data_loader(name, train=True, get_dataset=False): """Get data loader by name.""" if name == "MNIST": return get_mnist(train, get_dataset) elif name == "MNIST-M": return get_mnist_m(train, get_dataset) elif name == "SVHN": return get_svhn(train, get_dataset) elif name == "USPS": return get_usps(train, get_dataset)
def get_data_loader(name, train=True): """Get data loader by name.""" if name == "MNIST": return get_mnist(train) elif name == "USPS": return get_usps(train) elif name == "CIFAR10": return get_cifar10(train) elif "CIFAR10-" in name: corruption = name.split('-')[1] return get_cifar10(train, corruption=corruption)
def get_data_loader(name, train=True,domain=None,visualize=False): """Get data loader by name.""" if name == "MNIST": raise NotImplementedError return get_mnist(train) elif name == "USPS": raise NotImplementedError return get_usps(train) elif name == "Dollarstreet": return get_dollarstreet(visualize,domain) else: raise NotImplementedError
def get_data_loader(name, train=True): """Get data loader by name.""" if name == "MNIST": dataset = get_mnist(train) elif name == "MNISTM": dataset = get_mnistm(train) elif name == "USPS": dataset = get_usps(train) elif name == "SVHN": dataset = get_svhn(train) if train: data_loader = torch.utils.data.DataLoader(dataset=dataset, batch_size=params.batch_size, shuffle=True) else: data_loader = torch.utils.data.DataLoader(dataset=dataset, batch_size=1, shuffle=False) return data_loader
def get_data_loader(name, train=True, dataset=None, sample=False): """Get data loader by name.""" if name == "MNIST": return get_mnist(train, sample) elif name == "MNIST-M": return get_mnist_m(train) elif name == "SVHN": return get_svhn(train) elif name == "USPS": return get_usps(train, sample) elif name == "SYNTH": return get_synth(train) elif name == "SYNTHSIGN": return get_synthsign(train) elif name == "GTSRB": return get_gtsrb(train) elif name == "STL": return get_stl(train) elif name == "CIFA": return get_cifa(train) elif name == "PIE27": return get_pie27(train) elif name == "PIE05": return get_pie05(train) elif name == "PIE09": return get_pie09(train) elif name == "PIE37": return get_pie37(train) elif name == "PIE25": return get_pie25(train) elif name == "PIE02": return get_pie02(train) elif name == "taskcv_S": return get_taskcv_s(train) elif name == "taskcv_T": return get_taskcv_t(train) elif name == "OFFICE": return get_office(dataset)
import clusters import datasets as ds import estimate_k as ek from sklearn.cluster import KMeans from sklearn.cluster import SpectralClustering from pymongo import MongoClient # prepare datasets # uci uci_data, uci_target = ds.get_uci() uci_data = uci_data.astype('float32') / 16. # usps usps_data, _, usps_test, usps_test_lable = ds.get_usps() # mnist mnist_train,_,mnist_test,mnist_test_lable = ds.get_mnist() mnist_train = mnist_train.astype('float32') / 255. mnist_train = mnist_train.reshape((len(mnist_train),np.prod(mnist_train.shape[1:]))) # make 28*28 img to 784 demission matrix mnist_test = mnist_test.astype('float32') / 255. mnist_test = mnist_test.reshape((len(mnist_test), np.prod(mnist_test.shape[1:]))) # fashion fashion_train,_,fashion_test,fashion_test_lable = ds.get_fashion_mnist() fashion_train = fashion_train.astype('float32') / 255. fashion_train = fashion_train.reshape((len(fashion_train),np.prod(fashion_train.shape[1:]))) # make 28*28 img to 784 demission matrix fashion_test = fashion_test.astype('float32') / 255. fashion_test = fashion_test.reshape((len(fashion_test), np.prod(fashion_test.shape[1:])))