-3
Ich versuche, einige Informationen zu speichern und erhalte ich die Fehler
„Kann nicht‚schweben‘Objekt konvertieren implizit auf str“ I str wurde mit (statt Format), aber es zeigte der gleiche Fehler Bitte helfen thx.umwandeln kann nicht ‚schweben‘ Objekt implizit auf str [Loggin]
def save_model(json_string, dirpath='results/'):
with open(dirpath + starttime +'.txt', 'w') as f:
f.write(json_string)
def save_config(config, dirpath='results/'):
with open(dirpath + 'config_log.txt', 'a') as f:
f.write(starttime + '\n')
f.write((config) + '\n')
def save_result(starttime, conv_arch, dense, train_acc, val_acc, dirpath='results/'):
with open(dirpath + starttime +'_train_val.txt', 'w') as f:
f.write("{0}".format(train_acc) + '\n')
f.write("{0}".format(val_acc) + '\n')
endtime = time.asctime(time.localtime(time.time()))
with open(dirpath + 'result_log.txt', 'a') as f:
f.write(starttime + '--' + endtime + ' comment: ' + notes + '\n')
f.write("{0}".format(conv_arch) + ',{0}'.format(dense) + '\n')
f.write('Train acc: {0}'.format(train_acc[-1]) +
'Val acc: {0}'.format(val_acc[-1]) +
'Ratio: {0}'.format(val_acc[-1]/train_acc[-1]) + '\n')
hier ist der Ausgang
INFO - File "cnn6.py", line 109, in cnn_architecture
INFO - dropout, X_shape, y_shape, train_acc, val_acc, dirpath)
INFO - File "cnn6.py", line 33, in logging
INFO - save_result(starttime, conv_arch, dense, train_acc, val_acc, now)
INFO - File "/code/log.py", line 20, in save_result
INFO - with open(dirpath + starttime +'_train_val.txt', 'w') as f:
INFO - TypeError: Can't convert 'float' object to str implicitly
Können Sie ein bisschen mehr beschreiben? Fehlermeldung? – agaidis
'train_acc = train_acc'? 'val_acc = val_acc'? – Mangohero1
Ich habe nicht auf diese Zeilen geachtet. Ich habe die Namen der Funktion save_result geändert und diese beiden Zeilen nicht entfernt. – Oussama