Пример #1
0
p = '/vagrant/imgs/training_data/training_data/aligned'
d = os.listdir(p)

def _parse_function(filename):
    image_string = tf.read_file(filename)
    image_decoded = tf.image.decode_png(image_string, channels=3)
    image_resized = tf.image.resize_images(image_decoded, [95, 95])
    return image_resized

EPOCHS = 10
BATCH_SIZE = 16

filenames = [os.path.join(p, img_path) for img_path in d[:5]]
a = Attribute()
labels = np.array([a.get_attributes_list(img_path) for img_path in d[:5]])
# labels = labels.reshape(labels[0], labels[1], -1, -1)
print (labels.shape)
# labels = tf.constant(l)

features = [_parse_function(img_path) for img_path in d[:5]]
print([feature.shape for feature in features])
dataset = tf.data.Dataset.from_tensor_slices((features, labels)).repeat().batch(BATCH_SIZE)

# dataset = dataset.map(_parse_function)
iterator = dataset.make_one_shot_iterator()
x, y = iterator.get_next()

net = tf.layers.dense(x, 8, activation=tf.tanh) # pass the first value from iter.get_next() as input
net = tf.layers.dense(net, 8, activation=tf.tanh)
prediction = tf.layers.dense(net, 1, activation=tf.tanh)