'Experiment10(VGG16): Train the model for diagnosing the heart disease by the ECG.' ) parser.add_argument( '-c', '--config', type=str, default='./Config/config.ini', metavar='str', help="the path of configure file (default: './Config/config.ini')") Args = parser.parse_args() # the Arguments Args = read_config.read(Args) # read configure file #%% Main Function if __name__ == '__main__': #%% ########## Read Data ########## print('read data') ECG_data, ECG_label = read_data.extract_data( read_data.read_data(Args)) # read data #%% ########## Data Processing ########## ECG_data = data_process.cut_out(ECG_data, Args.len) # cut out the ECG signals ECG_data = data_process.axis_change(ECG_data) # change the axis ECG_label = data_process.label_from_0(ECG_label) # label from 0 # split data train_x, test_x, train_y, test_y = data_process.train_test_split( ECG_data, ECG_label, trainratio=Args.trainratio, random_state=0) # change to Tensor train_x, train_y = data_process.to_tensor(train_x, train_y) test_x, test_y = data_process.to_tensor(test_x, test_y) #%% ########## Load Data ########## # change to dataset train_dataset = Data.TensorDataset(train_x, train_y) test_dataset = Data.TensorDataset(test_x, test_y)
import read_data as rd import tensorflow as tf import numpy as np BATCH_SIZE = 10 EPOC = 5 import os dir_path = os.path.dirname(__file__) #<-- absolute dir the script is in file_path = os.path.join(dir_path, "data.csv") data_cols = rd.extract_data(file_path) #place holder for x X = tf.placeholder(tf.float32, [None, 2]) W = tf.Variable(tf.zeros([2, 1], tf.float32)) B = tf.Variable(tf.zeros([1], tf.float32)) Y_pred = tf.matmul(X, W) train_x = [] with tf.Session() as sess: sess.run(tf.global_variables_initializer()) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) for i in range(BATCH_SIZE): # Retrieve a single instance: features_result = sess.run(data_cols)