Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'dict_values' object is not subscriptable

best_params_train = dict(optimizer=optimizers[0], learning_rate=learning_rates[0],
                         cnn_train_type=cnn_train_types[0], 
                         cnn_arch=cnns_arch.values()[0],
                         dropout=dropouts[0])

it gives error at cnn_arch=cnns_arch.values()[0] as TypeError: 'dict_values' object is not subscriptable. i tried converting into list but not worked. how to convert the above dict(....) into list

exp_params_train = dict(optimizer=optimizers[1:], learning_rate=learning_rates[1:],
                        cnn_train_type=cnn_train_types[1:], dropout=dropouts[1:],
                        cnn_arch=cnns_arch.values())
like image 565
Sagar Telangi Avatar asked Apr 01 '26 20:04

Sagar Telangi


1 Answers

Quite on the contrary, it will work if you convert the dict_values object to a list:

cnn_arch=list(cnns_arch.values())[0]
like image 121
ForceBru Avatar answered Apr 03 '26 08:04

ForceBru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!