def __init__(self, input_shape, clients_num):
     (train_images, train_labels), (test_images, test_labels) = datasets.mnist.load_data()
     self.test_images = np.load("FL_QR_mnist//data//test_R.npy")
     self.test_labels = test_labels
     self.clients_num = clients_num
     self.model = D_CNN(input_shape)
     self.train_images = train_x(clients_num)
     self.train_labels = train_y(clients_num)
Exemple #2
0
 def __init__(self, input_shape, clients_num):
     (train_images,
      train_labels), (test_images,
                      test_labels) = datasets.mnist.load_data()
     self.test_images = test_images
     self.test_labels = test_labels
     self.clients_num = clients_num
     self.model = D_CNN(input_shape)
     self.dataset = Dataset(clients_num)
Exemple #3
0
from tensorflow.keras import datasets

(train_images, train_labels), (test_images,
                               test_labels) = datasets.mnist.load_data()
train_images_Q = np.load(
    "FL_QR_mnist//data//train_Q.npy")  # "solve_DL_gradient//train_gam_32.npy"
test_images_Q = np.load(
    "FL_QR_mnist//data//test_Q.npy")  # "solve_DL_gradient//test_gam_32.npy"
train_images_R = np.load("FL_QR_mnist//data//train_R.npy")
test_images_R = np.load("FL_QR_mnist//data//test_R.npy")

train_labels_OneHot = to_categorical(train_labels)
test_labels_OneHot = to_categorical(test_labels)

############################# all
model = D_CNN((28, 28, 1))
model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])
train_images = train_images[:500].reshape(-1, 28, 28, 1)
model.fit(train_images,
          train_labels_OneHot[:500],
          batch_size=128,
          epochs=20,
          validation_split=0.2)

test_images = test_images.reshape(10000, 28, 28, 1)
score = model.evaluate(test_images, test_labels_OneHot)
model.save("za_all//all_local.h5")
#########################    Q_CNN   ###############
model = D_CNN((28, 28, 1))