型。预测给出所有相同的输出
验证和测试精度< 60%
我尝试将最后一个隐藏层更改为softmax,但它仍然没有解决这个问题。任何反馈将不胜感激。我也尝试过使用超参数,但我仍然找不到任何修复程序。
raw_cvs_data = np.loadtxt('data_to_train.csv',delimiter=',')
raw_cvs_data_to_compute = np.loadtxt('data_to_compute.csv',delimiter=',')
unscaled_inputs_all = raw_cvs_data[:,1:]
targets_all = raw_cvs_data[:,0]
inputs_to_compute = raw_cvs_data_to_compute[:]
predicted_target=[]
# balancing the dataset
num_one_targets = int(np.sum(targets_all)) # count how many targets are 1
zero_targets_counter = 0 # counter for target 0
indices_to_remove = [] # remove extra input/target pairs for balance
# count the number of targets 0, when get same amount of target 1 and 0, make entries where target is zero
for i in range(targets_all.shape[0]):
if targets_all[i] == 0:
zero_targets_counter +=1
if zero_targets_counter > num_one_targets:
indices_to_remove.append(i)
unscaled_inputs_equal_priors = np.delete(unscaled_inputs_all,indices_to_remove, axis = 0)
targets_equal_priors = np.delete(targets_all, indices_to_remove, axis = 0)
#Shuffle the data
shuffled_indices = np.arange(scaled_inputs.shape[0])
np.random.shuffle(shuffled_indices) #shuffle pairs
shuffled_inputs = scaled_inputs[shuffled_indices]
shuffled_targets = targets_equal_priors[shuffled_indices]
# splitting data
samples_count = shuffled_inputs.shape[0]
# |training|validation|testing| 80-10-10
train_samples_count = int(0.8 * samples_count)
validation_samples_count = int(0.1 *samples_count)
test_samples_count = samples_count - train_samples_count - validation_samples_count
train_inputs = shuffled_inputs[:train_samples_count]
train_targets = shuffled_targets[:train_samples_count]
慕村225694
幕布斯7119047
相关分类