batch_size = 10 input_shape = [3, 60, 40]; def random_matrix(shape, np_rng, name=None,type=floatX): return theano.shared(np.require(np_rng.randn(*shape), dtype=type), borrow=True, name=name) # define inputs and filters in_time = 7 in_channels, in_width, in_height = input_shape; flt_channels = 10 flt_time = 2 flt_width = 3 flt_height = 4 rng = np.random.RandomState(42) #(batch, row, column, time, in channel) train_x = random_matrix((batch_size, in_height, in_width, in_time, in_channels),rng, 'x'); train_y = random_matrix((batch_size,),rng,'y',type=np.dtype('int32')); valid_x = random_matrix((batch_size, in_height, in_width, in_time, in_channels),rng, 'x'); valid_y = random_matrix((batch_size,),rng,'y',type=np.dtype('int32')); numpy_rng = np.random.RandomState(89677) #theano_rng = RandomStreams(numpy_rng.randint(2 ** 30)) cnn = CNN(numpy_rng,batch_size=batch_size, n_outs=10,conv_layer_configs = conv_layer_configs, hidden_layer_configs=hidden_layer_configs); train_fn, validate_fn = cnn.build_finetune_functions((train_x,train_y), (valid_x,valid_y), batch_size=batch_size)
# define inputs and filters in_time = 7 in_channels, in_width, in_height = input_shape flt_channels = 10 flt_time = 2 flt_width = 3 flt_height = 4 rng = np.random.RandomState(42) #(batch, row, column, time, in channel) train_x = random_matrix( (batch_size, in_height, in_width, in_time, in_channels), rng, 'x') train_y = random_matrix((batch_size, ), rng, 'y', type=np.dtype('int32')) valid_x = random_matrix( (batch_size, in_height, in_width, in_time, in_channels), rng, 'x') valid_y = random_matrix((batch_size, ), rng, 'y', type=np.dtype('int32')) numpy_rng = np.random.RandomState(89677) #theano_rng = RandomStreams(numpy_rng.randint(2 ** 30)) cnn = CNN(numpy_rng, batch_size=batch_size, n_outs=10, conv_layer_configs=conv_layer_configs, hidden_layer_configs=hidden_layer_configs) train_fn, validate_fn = cnn.build_finetune_functions((train_x, train_y), (valid_x, valid_y), batch_size=batch_size)