import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('opencv_logo.png') kernel = np.ones((5,5),np.float32)/25 dst = cv2.filter2D(img,-1,kernel) plt.subplot(121),plt.imshow(img),plt.title('Original') plt.xticks([]), plt.yticks([]) plt.subplot(122),plt.imshow(dst),plt.title('Averaging') plt.xticks([]), plt.yticks([]) plt.show()
Sunday, October 20, 2019
opencv filter
Wednesday, October 09, 2019
Contoh ReadData pada Google
from keras.models import Sequential
from keras.layers import Dense
import numpy
from scipy.spatial import Delaunay
import pandas as pd
def ReadData(sf):
sdir="drive/My Drive/Colab Notebooks"
sff="%s/%s"%(sdir ,sf)
print("Baca file :",sff)
df = array(pd.read_csv(sff,header=None))
df1 = pd.DataFrame(df)
return df1.values
def SaveData(sf,m):
sdir="drive/My Drive/Colab Notebooks"
sff="%s/%s"%(sdir ,sf)
print("Simpan File :",sff)
savetxt(sff, m, delimiter=',',newline='\r\n')
# load and prepare the dataset
#dataset = numpy.loadtxt("cb.csv", delimiter=",")
#X = dataset[:,0:8]
#Y = dataset[:,8]
X=numpy.array([[0,0],[0,1],[1,0],[1,1]]);
Y=numpy.array([[0],[1],[1],[0]]);
# 1. define the network
model = Sequential()
model.add(Dense(1000, input_dim=2, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
# 2. compile the network
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# 3. fit the network
history = model.fit(X, Y, epochs=10000, batch_size=1)
#history = model.fit(X, Y, epochs=2000)
# 4. evaluate the network
loss, accuracy = model.evaluate(X, Y)
print("\nLoss: %.2f, Accuracy: %.2f%%" % (loss, accuracy*100))
# 5. make predictions
probabilities = model.predict(X)
predictions = [float(numpy.round(x)) for x in probabilities]
accuracy = numpy.mean(predictions == Y)
print("Prediction Accuracy: %.2f%%" % (accuracy*100))
Subscribe to:
Posts (Atom)