示例#1
0
def config_tf():
    from mCNN.queueGPU import queueGPU
    CUDA_rate = '0.25'
    ## config TF
    queueGPU(USER_MEM=3500, INTERVAL=60)
    # os.environ['CUDA_VISIBLE_DEVICES'] = CUDA
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    if CUDA_rate != 'full':
        config = tf.ConfigProto()
        if float(CUDA_rate) < 0.1:
            config.gpu_options.allow_growth = True
        else:
            config.gpu_options.per_process_gpu_memory_fraction = float(CUDA_rate)
        set_session(tf.Session(config=config))
示例#2
0
    #     objective = pearson_coeff * 2 + std
    #     return {'loss': -objective, 'status': STATUS_OK}
    #
    # elif obj == 'val_mae':
    #     validation_mae = np.amax(result.history['val_mean_absolute_error'])
    #     print('Best validation mae of epoch:', validation_mae)
    #     return {'loss': validation_mae, 'status': STATUS_OK}


if __name__ == '__main__':
    import sys
    neighbor_obj, CUDA_rate = sys.argv[1:]
    ## config TF
    #os.environ['CUDA_VISIBLE_DEVICES'] = '0'
    from mCNN.queueGPU import queueGPU
    queueGPU()
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

    if CUDA_rate != 'full':
        config = tf.ConfigProto()
        if float(CUDA_rate) < 0.1:
            config.gpu_options.allow_growth = True
        else:
            config.gpu_options.per_process_gpu_memory_fraction = float(
                CUDA_rate)
        set_session(tf.Session(config=config))

    x_train, y_train, ddg_train, x_test, y_test, ddg_test, class_weights_dict, obj, kneighbor = data(
        neighbor_obj)
    model = Conv2DRegressorIn1(x_train, y_train, ddg_train, x_test, y_test,
                               ddg_test, class_weights_dict, obj, kneighbor)
        y=ddg_train,
        batch_size=batch_size,
        epochs=epochs,
        verbose=verbose,
        callbacks=my_callbacks,
        validation_data=(x_val, ddg_val),
        shuffle=True,
    )
    return network, result.history


if __name__ == '__main__':
    from mCNN.queueGPU import queueGPU
    CUDA_rate = '0.2'
    ## config TF
    queueGPU(USER_MEM=3000, INTERVAL=60)
    # os.environ['CUDA_VISIBLE_DEVICES'] = CUDA
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    if CUDA_rate != 'full':
        config = tf.ConfigProto()
        if float(CUDA_rate) < 0.1:
            config.gpu_options.allow_growth = True
        else:
            config.gpu_options.per_process_gpu_memory_fraction = float(
                CUDA_rate)
        set_session(tf.Session(config=config))

    # modeldir = '/dl/sry/mCNN/src/Network/deepddg/regressor/TrySimpleConv1D_CrossValid_%s'%time.strftime("%Y.%m.%d.%H.%M.%S", time.localtime())
    modeldir = '/dl/sry/mCNN/src/Network/deepddg/regressor/%s_%s' % (
        sys.argv[0][:-3], time.strftime("%Y.%m.%d.%H.%M.%S", time.localtime()))
    os.makedirs(modeldir, exist_ok=True)