ในบทความนี้ เราจะเรียนรู้เกี่ยวกับการโน้มน้าวใจใน Python 3.x หรือก่อนหน้านี้ บทความนี้อยู่ภายใต้โครงข่ายประสาทเทียมและการแยกคุณลักษณะ
Ide ที่ต้องการ − สมุดบันทึก Jupyter
ข้อกำหนดเบื้องต้น − ติดตั้ง Numpy, ติดตั้ง Matplotlib แล้ว
การติดตั้ง
>>> pip install numpy >>>pip install matplotlib
บิดเบี้ยว
Convolution เป็นการดำเนินการประเภทหนึ่งที่สามารถทำได้บนรูปภาพเพื่อแยกคุณลักษณะออกจากรูปภาพโดยใช้คอนเทนเนอร์ขนาดเล็กกว่าที่เรียกว่าเคอร์เนล/คอนเทนเนอร์พิกัด เช่น หน้าต่างเลื่อนเหนือรูปภาพ เราสามารถรับรูปแบบ/คุณลักษณะเฉพาะจากรูปภาพได้ ทั้งนี้ขึ้นอยู่กับค่าในคอนเทนเนอร์พิกัดแบบบิดเบี้ยว ที่นี่ เราจะเรียนรู้เกี่ยวกับการตรวจหาจุดปลายแนวนอนและแนวตั้งในรูปภาพโดยใช้คอนเทนเนอร์พิกัดที่เหมาะสม
มาดูการใช้งานจริงกัน
ตัวอย่าง
import numpy as np from matplotlib import pyplot # initializing the images img1 = np.array([np.array([100, 100]), np.array([80, 80])]) img2 = np.array([np.array([100, 100]), np.array([50, 0])]) img3 = np.array([np.array([100, 50]), np.array([100, 0])]) coordinates_horizontal = np.array([np.array([3, 3]), np.array([-3, -3])]) print(coordinates_horizontal, 'is a coordinates for detecting horizontal end points') coordinates_vertical = np.array([np.array([3, -3]), np.array([3, - 3])]) print(coordinates_vertical, 'is a coordinates for detecting vertical end points') #his will be an elemental multiplication followed by addition def apply_coordinates(img, coordinates): return np.sum(np.multiply(img, coordinates)) # Visualizing img1 pyplot.imshow(img1) pyplot.axis('off') pyplot.title('sample 1') pyplot.show() # Checking for horizontal and vertical features in image1 print('Horizontal end points features score:', apply_coordinates(img1, coordinates_horizontal)) print('Vertical end points features score:', apply_coordinates(img1,coordinates_vertical)) # Visualizing img2 pyplot.imshow(img2) pyplot.axis('off') pyplot.title('sample 2') pyplot.show() # Checking for horizontal and vertical features in image2 print('Horizontal end points features score:', apply_coordinates(img2, coordinates_horizontal)) print('Vertical end points features score:', apply_coordinates(img2, coordinates_vertical)) # Visualizing img3 pyplot.imshow(img3) pyplot.axis('off') pyplot.title('sample 3') pyplot.show() # Checking for horizontal and vertical features in image1 print('Horizontal end points features score:', apply_coordinates(img3,coordinates_horizontal)) print('Vertical end points features score:', apply_coordinates(img3,coordinates_vertical))
ผลลัพธ์
บทสรุป
ในบทความนี้ เราได้เรียนรู้เกี่ยวกับ Introduction-to-Convolutions-using-python 3.x หรือก่อนหน้า &การนำไปใช้