'valid_set': BatchIterator('continuous'), 'test_set': BatchIterator('continuous') }, device="/cpu:0") # Create Network #--------------- # we use a batch_size of 64 and use the dataset.datum shape to # obtain the shape of 1 observation and create the input shape K = 8 my_layer = layers.custom_layer(ops.Dense, ops.BatchNorm, ops.Activation) dnn = sknet.network.Network(name='simple_model') dnn.append(ops.RandomCrop(dataset.images, (28, 28))) dnn.append( layers.Conv2D(dnn[-1], [(64, 3, 3), { 'b': None, 'pad': 'same' }], [[0, 2, 3]], [0.01])) dnn.append(my_layer(dnn[-1], [10, {'b': None}], [0], [tf.identity])) dnn.append( layers.Conv2DPool(dnn[-2], [(192, 3, 3), { 'b': None, 'pad': 'same' }], [[0, 2, 3]], [0.01], [(1, 2, 2)])) dnn.append(my_layer(dnn[-1], [10, {'b': None}], [0], [tf.identity]))
return tf.abs(tensor[:,c])/norm distances = tf.map_fn(doit,tf.range(tensor.shape.as_list()[1]), dtype=tf.float32) return tf.reduce_min(distances,0) # Create Network #--------------- dnn = sknet.Network(name='simple_model') if DATA_AUGMENTATION: dnn.append(ops.RandomAxisReverse(dataset.images,axis=[-1])) dnn.append(ops.RandomCrop(dnn[-1],(28,28),seed=10)) start_op = 2 else: dnn.append(dataset.images) start_op = 1 if MODEL=='cnn': sknet.networks.ConvSmall(dnn,dataset.n_classes) elif MODEL=='dense': dnn.append(sknet.ops.Dense(dnn[-1],4096)) dnn.append(sknet.ops.BatchNorm(dnn[-1],0)) dnn.append(sknet.ops.Activation(dnn[-1],0.1)) dnn.append(sknet.ops.Dense(dnn[-1],2048)) dnn.append(sknet.ops.BatchNorm(dnn[-1],0)) dnn.append(sknet.ops.Activation(dnn[-1],0.1))
'train_set': 'random_see_all', 'test_set': 'continuous' }) dataset.create_placeholders(iterator, device="/cpu:0") # Create Network #--------------- # we use a batch_size of 64 and use the dataset.datum shape to # obtain the shape of 1 observation and create the input shape dnn = sknet.Network(name='simple_model') dnn.append(ops.RandomAxisReverse(dataset.images, axis=[-1])) dnn.append(ops.RandomCrop(dnn[-1], (28, 28))) if MODEL == 'smallcnn': sknet.networks.ConvSmall(dnn, dataset.n_classes) all_layers = dnn[2:-1].as_list() elif MODEL == 'largecnn': sknet.networks.ConvLarge(dnn, dataset.n_classes) all_layers = dnn[2:-1].as_list() else: sknet.networks.Resnet(dnn, dataset.n_classes, D=2, W=2) all_layers = [ layer for layer in dnn[2:-1] if type(layer) == sknet.ops.Merge ] prediction = dnn[-1]