def HappyModel(input_shape): X_input = Input(input_shape) X = ZeroPadding2D((3,3))(X_input) X = Conv2D(18,(7,7),strides=(1,1),name="conv0")(X) X = BatchNormalization(axis=3, name="bn0")(X) X = Activation("relu")(X) X = MaxPooling2D((2,2), name="max_pool")(X) X = Flatten()(X) X = Dense(1,activation="sigmoid", name="fC")(X) model = Model(input = X_input, outputs = X, name="happy model") return model happyModel = HappyModel(X_train.shape[1:]) happyModel.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"]) happyModel.fit(x=X_train, y=Y_train,epochs=10, batch_size=20) preds = happyModel.evaluate(x=X_test,y=Y_test) img_path = 'images/smile.jpg' img = image.load_img(img_path, target_size=(64, 64)) imshow(img) x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x) print(happyModel.predict(x))
Friday, October 9, 2020
Code Assignment
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment