Esempio n. 1
0
    with tf.Graph().as_default() as graph:
        with tf.compat.v1.Session() as sess:
            tf.constant([imageHeight,imageWidth], dtype="float32",name = "imageSize")
            tf.constant([outputTensorName], name = "OutputTensorName")
            X = tf.compat.v1.placeholder(tf.float32, [None, imageHeight,imageWidth,1], name='Input')
            Y = tf.compat.v1.placeholder(tf.float32, [None, imageHeight,imageWidth,1])
            Z = tf.compat.v1.placeholder(tf.float32, [None, 300], name = 'InputLatentVector')
            isTrain = tf.compat.v1.placeholder(tf.bool, name="isTrain");

            model = Model(X,Y,Z,isTrain,learningRate)
            prediction = model.prediction()
            error = model.error()
            data.add_variable_summary(error, "Loss")
            optimizer = model.optimize()
            #train_dataset, val_dataset, test_dataset = data.createTensorflowDatasets(0.8,0.1,0.1)
            train_dataset, val_dataset = data.createTensorflowDatasets()
            merged_summary_operation = tf.compat.v1.summary.merge_all()
            modelname = "model_" + "learningRate_" + str(model.learningRate) + "epochs_" + str(epochs) + "_channelsize_" + str(channelSize) + loss
            print (modelname)
            train_summary_writer = tf.compat.v1.summary.FileWriter(savePath + modelname + '/tmp/' + modelname + "train")
            validation_summary_writer = tf.compat.v1.summary.FileWriter(savePath + modelname + '/tmp/' + modelname+ "validation")
            init = tf.compat.v1.global_variables_initializer()
            init_l = tf.compat.v1.local_variables_initializer()
            sess.run(init)
            sess.run(init_l)
            print("Initialisation completed")
            flops = tf.compat.v1.profiler.profile(graph,options=tf.compat.v1.profiler.ProfileOptionBuilder.float_operation())
            print('FLOP = ', flops.total_float_ops)
            print("Initialisation completed")
            trainingClass = train(sess,data,optimizer,error,model,merged_summary_operation)
            for epoch in range(epochs):
Esempio n. 2
0
    return int(Datasize/batchSize)

with tf.Graph().as_default() as graph:
    with tf.Session() as sess:


        tf.constant([imageHeight,imageWidth], dtype="float32",name = "imageSize")
        tf.constant([outputTensorName], name = "OutputTensorName")
        X = tf.placeholder(tf.float32, [None, imageHeight,imageWidth,1], name='Input')
        Y = tf.placeholder(tf.float32, [None, imageHeight,imageWidth,5])
        model = Model(X,Y,learningRate)
        prediction = model.prediction()
        error = model.error()
        data.add_variable_summary(error, "Loss")
        optimizer = model.optimize()
        train_dataset, val_dataset, test_dataset = data.createTensorflowDatasets(0.8,0.1,0.1)
        merged_summary_operation = tf.summary.merge_all()
        modelname = "model_" + "learningRate_" + str(model.learningRate) + "epochs_" + str(epochs) 
        print (modelname) 
        train_summary_writer = tf.summary.FileWriter(savePath + modelname + '/tmp/' + modelname + "train")
        validation_summary_writer = tf.summary.FileWriter(savePath + modelname + '/tmp/' + modelname+ "validation")
        init = tf.global_variables_initializer()
        init_l = tf.local_variables_initializer()
        sess.run(init)
        sess.run(init_l)
        print("Initialisation completed")
        trainingClass = train(sess,data,optimizer,error,model,merged_summary_operation)
        for epoch in range(epochs):
            print ("Current epoch is",epoch)
            batches = getnumberofBatches(data.train_size, trainbatchSize)
            print ("Number of batches", batches)