コード例 #1
0
ファイル: convnet.py プロジェクト: vyraun/conv-net-research
	def initialize_mnist(self):
		# This method is provided as an example of how to use the provided
		# initialize_dataset method for a given set of data with known shapes.
		import sys
		sys.path.append("..")
		from datasets.Load import mnist
		trX, trY, teX, teY = mnist(onehot = True)
		shape_dict = {
			"w1": (32, 1, 3, 3),
			"w2": (64, 32, 3, 3),
			"w3": (128, 64, 3, 3),
			"w4": (128 * 3 * 3, 625),
			"wo": (625, 10)
		}
		self.initialize_dataset(trX, trY, teX, teY, shape_dict)
		return self
コード例 #2
0
            for o in parser.option_list
        ])
        length_help = max([len(o.help) for o in parser.option_list])
        print("\n" + parser.description + "\n")
        for option in parser.option_list:
            print("  {0: <{1}}   {2: <{3}}   (default: {4})".format(
                ", ".join(option._short_opts + option._long_opts), length_name,
                option.help, length_help, option.default))
        print("")
        sys.exit()

    if options.clock:
        start = time.time()

    # load data
    trX09, trY09, teX09, teY09 = mnist(onehot=False)

    # prep training data
    trX08, trY08, trX_9, trY_9 = remove_class(trX09, trY09, 9)
    trX07, trY07, trX_8, trY_8 = remove_class(trX08, trY08, 8)

    # prep testing data
    teX08, teY08, teX_9, teY_9 = remove_class(teX09, teY09, 9)
    teX07, teY07, teX_8, teY_8 = remove_class(teX08, teY08, 8)

    # initialize, train, and evaluate multi-net model on classes 0-7
    print("Batch training model on starting tasks 0-7...")
    mnm = MultiNetModel(options.mode).train(trX07,
                                            trY07,
                                            epochs=options.epochs,
                                            verbose=options.verbose)
コード例 #3
0
import numpy as np
import sys
sys.path.append("..")
from convnet import ConvolutionalNeuralNetwork
from datasets.Load import mnist, cifar10

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: {filename} <dataset>".format(
            filename=sys.argv[0].split("/")[-1]))
        sys.exit(1)

    dataset = sys.argv[1].lower()

    if dataset == "mnist":
        trX, trY, teX, teY = mnist(onehot=True)
        shape_dict = {
            "w1": (32, 1, 3, 3),
            "w2": (64, 32, 3, 3),
            "w3": (128, 64, 3, 3),
            "w4": (128 * 3 * 3, 625),
            "wo": (625, 10)
        }

    elif dataset == "cifar":
        trX, trY, teX, teY = cifar10(onehot=True)
        shape_dict = {
            "w1": (32, 1, 3, 3),
            "w2": (64, 32, 3, 3),
            "w3": (128, 64, 3, 3),
            "w4": (128 * 3 * 3, 841),
コード例 #4
0
	# custom help message
	if options.help:
		length_name = max([len(", ".join(o._short_opts + o._long_opts)) for o in parser.option_list])
		length_help = max([len(o.help) for o in parser.option_list])
		print("\n" + parser.description + "\n")
		for option in parser.option_list:
			print("  {0: <{1}}   {2: <{3}}   (default: {4})".format(", ".join(option._short_opts + option._long_opts), length_name, option.help, length_help, option.default))
		print("")
		sys.exit()

	if options.clock:
		start = time.time()

	# load data
	trX09, trY09, teX09, teY09 = mnist(onehot = False)

	# prep training data
	trX08, trY08, trX_9, trY_9 = remove_class(trX09, trY09, 9)
	trX07, trY07, trX_8, trY_8 = remove_class(trX08, trY08, 8)

	# prep testing data
	teX08, teY08, teX_9, teY_9 = remove_class(teX09, teY09, 9)
	teX07, teY07, teX_8, teY_8 = remove_class(teX08, teY08, 8)

	# initialize, train, and evaluate multi-net model on classes 0-7
	print("Batch training model on starting tasks 0-7...")
	mnm = MultiNetModel(options.mode).train(trX07, trY07, epochs = options.epochs, verbose = options.verbose)
	if options.test:
		for t in range(8):
			print("Accuracy on task {0}: {1:0.04f}".format(t, mnm.test(teX07, teY07, t)))
コード例 #5
0
import numpy as np
import sys
sys.path.append("..")
from convnet import ConvolutionalNeuralNetwork
from datasets.Load import mnist, cifar10


if __name__ == "__main__":
	if len(sys.argv) < 2:
		print("Usage: {filename} <dataset>".format(filename = sys.argv[0].split("/")[-1]))
		sys.exit(1)

	dataset = sys.argv[1].lower()

	if dataset == "mnist":
		trX, trY, teX, teY = mnist(onehot = True)
		shape_dict = {
			"w1": (32, 1, 3, 3),
			"w2": (64, 32, 3, 3),
			"w3": (128, 64, 3, 3),
			"w4": (128 * 3 * 3, 625),
			"wo": (625, 10)
		}

	elif dataset == "cifar":
		trX, trY, teX, teY = cifar10(onehot = True)
		shape_dict = {
			"w1": (32, 1, 3, 3),
			"w2": (64, 32, 3, 3),
			"w3": (128, 64, 3, 3),
			"w4": (128 * 3 * 3, 841),