# 读完一个周期后重新开始 i = (i + 1) % n yield (np.array(X_train), np.array(Y_train)) def loss(y_true, y_pred): crossloss = K.binary_crossentropy(y_true, y_pred) loss = 16 * K.sum(crossloss) / HEIGHT / WIDTH return loss if __name__ == "__main__": log_dir = "logs/" # 获取model model = mobilenet_pspnet(n_classes=NCLASSES, input_height=HEIGHT, input_width=WIDTH) # model.summary() BASE_WEIGHT_PATH = ('https://github.com/fchollet/deep-learning-models/' 'releases/download/v0.6/') model_name = 'mobilenet_%s_%d_tf_no_top.h5' % ('1_0', 224) weight_path = BASE_WEIGHT_PATH + model_name weights_path = keras.utils.get_file(model_name, weight_path) print(weight_path) model.load_weights(weights_path, by_name=True, skip_mismatch=True) # model.summary() # 打开数据集的txt with open(r".\dataset2\train.txt", "r") as f: lines = f.readlines()
#---------------------------------------------# # 该部分用于查看网络结构 #---------------------------------------------# from nets.pspnet import mobilenet_pspnet if __name__ == "__main__": model = mobilenet_pspnet(2, 576, 576) model.summary()