當前位置: 首頁>>代碼示例>>Python>>正文


Python data.load_data方法代碼示例

本文整理匯總了Python中data.load_data方法的典型用法代碼示例。如果您正苦於以下問題:Python data.load_data方法的具體用法?Python data.load_data怎麽用?Python data.load_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在data的用法示例。


在下文中一共展示了data.load_data方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import data [as 別名]
# 或者: from data import load_data [as 別名]
def main():
  # format data
  data = load_data("german")

  # set the auditor
  auditor = Auditor()
  auditor.model = Weka_SVM

  # call the auditor
  auditor(data, output_dir="try", features_to_audit=["checking_status","duration"], dump_all=True) 
開發者ID:algofairness,項目名稱:BlackBoxAuditing,代碼行數:12,代碼來源:BlackBoxAuditor.py

示例2: main

# 需要導入模塊: import data [as 別名]
# 或者: from data import load_data [as 別名]
def main(argv=None):
    train_data, validate_data, test_data, mask = load_data(data_path, BATCH_SIZE)
    train(train_data, validate_data,test_data, mask) 
開發者ID:CedricChing,項目名稱:DeepMRI,代碼行數:5,代碼來源:run.py

示例3: run_lstm

# 需要導入模塊: import data [as 別名]
# 或者: from data import load_data [as 別名]
def run_lstm(model, sequence_length, prediction_steps):
    data = None
    global_start_time = time.time()
    epochs = 1
    ratio_of_data = 1  # ratio of data to use from 2+ million data points
    path_to_dataset = 'data/household_power_consumption.txt'

    if data is None:
        print('Loading data... ')
        x_train, y_train, x_test, y_test, result_mean = load_data(path_to_dataset, sequence_length,
                                                                  prediction_steps, ratio_of_data)
    else:
        x_train, y_train, x_test, y_test = data

    print('\nData Loaded. Compiling...\n')

    if model is None:
        model = build_model(prediction_steps)
        try:
            model.fit(x_train, y_train, batch_size=128, epochs=epochs, validation_split=0.05)
            predicted = model.predict(x_test)
            # predicted = np.reshape(predicted, (predicted.size,))
            model.save('LSTM_power_consumption_model.h5')  # save LSTM model
        except KeyboardInterrupt:  # save model if training interrupted by user
            print('Duration of training (s) : ', time.time() - global_start_time)
            model.save('LSTM_power_consumption_model.h5')
            return model, y_test, 0
    else:  # previously trained mode is given
        print('Loading model...')
        predicted = model.predict(x_test)
    plot_predictions(result_mean, prediction_steps, predicted, y_test, global_start_time)

    return None 
開發者ID:demmojo,項目名稱:lstm-electric-load-forecast,代碼行數:35,代碼來源:lstm.py

示例4: _get_buckets

# 需要導入模塊: import data [as 別名]
# 或者: from data import load_data [as 別名]
def _get_buckets():
    """ Load the dataset into buckets based on their lengths.
    train_buckets_scale is the inverval that'll help us 
    choose a random bucket later on.
    """
    test_buckets = data.load_data('test_ids.enc', 'test_ids.dec')
    data_buckets = data.load_data('train_ids.enc', 'train_ids.dec')
    train_bucket_sizes = [len(data_buckets[b]) for b in range(len(config.BUCKETS))]
    print("Number of samples in each bucket:\n", train_bucket_sizes)
    train_total_size = sum(train_bucket_sizes)
    # list of increasing numbers from 0 to 1 that we'll use to select a bucket.
    train_buckets_scale = [sum(train_bucket_sizes[:i + 1]) / train_total_size
                           for i in range(len(train_bucket_sizes))]
    print("Bucket scale:\n", train_buckets_scale)
    return test_buckets, data_buckets, train_buckets_scale 
開發者ID:chiphuyen,項目名稱:stanford-tensorflow-tutorials,代碼行數:17,代碼來源:chatbot.py


注:本文中的data.load_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。