Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python
Python
  1. วิธี Validate ข้อมูลด้วย Cerberus ใน Python

    บทนำCerberus เป็น validation libraryน้ำหนักเบา ขยายได้ ใช้ schema-based validation สำหรับ dict, JSON, config files ฯลฯการติดตั้งpip install Cerberusการใช้งานพื้นฐาน1. กำหนด Schema และ Validatefrom cerberus import Validator schema = {numbers: {type: integer}} v = Validator(schema) data = {numbers: 5}

  2. วิธีแสดงตัวอย่างข้อมูลจาก Abalone Dataset ด้วย TensorFlow

    บทนำหลังโหลด Abalone dataset ด้วย pandas read_csv ควรตรวจสอบข้อมูลด้วย head() และแยก features/labels ก่อน trainโค้ดตัวอย่างprint(Few samples of abalone data) abalone_train.head() print(The abalone dataset is copied to another memory location) abalone_features = abalone_train.copy() print(The age c

  3. วิธีสร้าง Sequential Model สำหรับ Abalone Dataset ด้วย TensorFlow

    บทนำสร้างโมเดล regression แบบง่ายด้วย Keras Sequential API เพื่อพยากรณ์อายุหอย (Abalone age) จากคุณสมบัติทางกายภาพโค้ดตัวอย่างprint(The sequential model is being built) abalone_model = tf.keras.Sequential([ layers.Dense(64), layers.Dense(1) ]) abalone_model.compile(loss=tf.losses.MeanSquared

  4. การอ่านและเขียนไฟล์ Excel ด้วย openpyxl ใน Python

    บทนำopenpyxl เป็น library สำหรับอ่าน/เขียนไฟล์ Excel 2010+ (.xlsx, .xlsm, .xltx, .xltm) ไม่รองรับ .xls เก่าการติดตั้งpip install openpyxlการ Importfrom openpyxl import Workbook import openpyxlสร้างและบันทึกไฟล์ Excelwb = Workbook() sheet = wb.active sheet[A1] = Hello sheet[A2] = World! sheet[A3] = 4

  5. วิธีสร้าง Normalization Layer สำหรับ Abalone Dataset ด้วย TensorFlow

    บทนำNormalization layer ช่วยปรับสเกลฟีเจอร์ให้อยู่ในช่วงที่เหมาะสม (mean=0, std=1) ซึ่งช่วยให้โมเดล converge เร็วและเสถียรขึ้นTensorFlow/Keras มี preprocessing.Normalization layer ที่คำนวณ mean/variance อัตโนมัติจาก training dataโค้ดตัวอย่างprint(A normalization layer is being built) normalize = pre

  6. Python OS Module คืออะไร และการใช้งานพื้นฐาน

    บทนำโมดูล os ให้ฟังก์ชันสำหรับโต้ตอบกับระบบปฏิบัติการ: จัดการไฟล์/โฟลเดอร์, environment variables, process controlการเริ่มต้นos มาพร้อม Python: import osฟังก์ชันหลักและตัวอย่าง1. os.getcwd() - โฟลเดอร์ทำงานปัจจุบันimport os os.getcwd()2. os.mkdir(path) - สร้างโฟลเดอร์import os os.mkdir(D:\\Tutorials

  7. หลัง Normalization แล้ว วิธี Train และ Build โมเดลด้วย TensorFlow

    บทนำหลังจากสร้าง normalization layer และเตรียมข้อมูล Abalone dataset (พยากรณ์อายุหอยจากขนาด/น้ำหนัก) ขั้นตอนต่อไปคือ compile และ fit โมเดลโค้ดตัวอย่างprint(The model is being compiled) norm_abalone_model.compile(loss=tf.losses.MeanSquaredError(), optimizer=tf.optimizers.Adam()) print(The model is b

  8. การแทนค่าและจัดการ Unicode Strings ใน TensorFlow

    บทนำTensorFlow ใช้ tf.string dtype สำหรับ byte strings (UTF-8 default) มี 2 วิธีหลักแทนค่า Unicode strings:String scalar: ลำดับ code points เข้ารหัสด้วย encoding ที่รู้จัก (UTF-8, UTF-16, etc.)Int32 vector: แต่ละตำแหน่งเก็บ code point เดียวโค้ดตัวอย่างimport tensorflow as tf print(A constant is defi

  9. การแปลงระหว่างรูปแบบ String Representations ต่างๆ ด้วย TensorFlow

    บทนำTensorFlow มี 3 operations หลักสำหรับแปลงระหว่างรูปแบบ string representations:unicode_decode: encoded string scalar → vector of code pointsunicode_encode: vector of code points → encoded string scalarunicode_transcode: encoded string scalar (encoding A) → encoded string scalar (encoding B)โค้ดตั

  10. Python sys Module คืออะไร และการใช้งานพื้นฐาน

    บทนำโมดูล sys ใน Python ให้ข้อมูลเกี่ยวกับ Python interpreter และอนุญาตให้เข้าถึงค่าคงที่ ฟังก์ชัน และเมธอดต่างๆ ของ interpreterการเริ่มต้นใช้งานsys มาพร้อมกับ Python ไม่ต้องติดตั้งเพิ่ม ใช้คำสั่ง import sysฟังก์ชันหลักและตัวอย่าง1. sys.argv - อ่าน аргументบรรทัดคำสั่ง# example.py import sys print(Y

  11. วิธีเข้ารหัสสตริงหลายสตริงที่มีความยาวเท่ากันด้วย TensorFlow และ Python

    บทนำtf.strings.unicode_encode เข้ารหัส code points → string รองรับ input 3 รูปแบบ:tf.Tensor (dense): เมื่อทุกสตริงมีจำนวน code points เท่ากัน (shape: [batch, seq_len])tf.RaggedTensor: เมื่อความยาวต่างกัน (ragged dimension)Sparse/Padded Tensor: แปลงเป็น RaggedTensor ก่อนด้วย from_sparse หรือ from_ten

  12. วิธีดำเนินการ Unicode Operations ใน TensorFlow ด้วย Python

    บทนำTensorFlow มี operations สำหรับวัดความยาวและแปลง encoding ของ Unicode strings:tf.strings.length: วัดความยาว (รองรับ unit: BYTE, UTF8_CHAR, UTF16_CHAR)tf.strings.unicode_encode: code points → encoded stringtf.strings.unicode_decode: encoded string → code pointstf.strings.unicode_transcode: แปลง e

  13. วิธีจัดการ Character Substring ด้วย TensorFlow และ Python

    บทนำtf.strings.substr ใช้ตัด substring แบบระบุตำแหน่งและความยาว รองรับหน่วยเป็น BYTE (default) หรือ UTF8_CHARโค้ดตัวอย่างprint(The default unit is byte) print(When len is 1, a single byte is returned) tf.strings.substr(thanks, pos=7, len=1).numpy() print(The unit is specified as UTF8_CHAR) print(It

  14. วิธีแยก Unicode String และระบุ Byte Offset ด้วย TensorFlow และ Python

    บทนำTensorFlow มี ops สำหรับจัดการ Unicode string ระดับตัวอักษร:tf.strings.unicode_split: แยก string เป็น substring ตัวอักษรเดี่ยวtf.strings.unicode_decode_with_offsets: decode พร้อมคืนค่า byte offset เริ่มต้นของแต่ละตัวอักษรโค้ดตัวอย่างprint(Split unicode strings) tf.strings.unicode_split(thanks, U

  15. Unicode Scripts ใน TensorFlow และ Python คืออะไร

    นิยามทุก Unicode code point 屬於 Script (สคริปต์/ระบบเขียน) หนึ่งเดียว เช่น Latin, Cyrillic, Han, Hiragana, Katakana, Thai, ฯลฯScript ช่วยระบุว่าตัวอักษรน่าจะมาจากภาษา/ระบบเขียนไหนTensorFlow Operationtf.strings.unicode_script(codepoints) คืนค่า int32 tensor รหัส script (mapping ไป ICU UScriptCode)โค้ด

  16. Segmentation ในข้อมูลข้อความ TensorFlow คืออะไร

    นิยามSegmentation (การแบ่งส่วน/แบ่งคำ) คือการแยกข้อความเป็นหน่วยคล้ายคำ (word-like units) ซึ่งจำเป็นเพราะ:ภาษาบางภาษา (จีน, ญี่ปุ่น, ไทย) ไม่ใช้ space คั่นคำภาษาบางภาษา (เยอรมัน) มีคำประสมยาวที่ต้องแยกเพื่อวิเคราะห์ความหมายข้อความบนเว็บมักผสมหลายสคริปต์ (เช่น NY株価 = New York + กุฑา)Unicode และ Code

  17. วิธีหา Code Point ของทุกคำในประโยคด้วย TensorFlow และ Python

    บทนำการหา word boundaries (ขอบเขตคำ) ในข้อความ Unicode ที่ผสมภาษา สามารถทำได้โดยใช้ script identifiers (รหัสสคริปต์) ของแต่ละตัวอักษรหลักการ: เริ่มคำใหม่ที่ (1) ตัวแรกของประโยค (2) ตัวอักษรที่มี script ต่างจากตัวก่อนหน้าโค้ดตัวอย่างprint(Check if sentence is the start of the word) sentence_char_star

  18. วิธีสร้าง Ragged Tensor จากรายการคำด้วย TensorFlow และ Python

    บทนำtf.RaggedTensor เหมาะสำหรับข้อมูลขนาดไม่เท่ากัน เช่น จำนวนคำต่อประโยค, จำนวนตัวอักษรต่อคำ ซึ่งแตกต่างจาก dense tensor ที่ต้อง paddingบทความนี้สาธิตการสร้าง RaggedTensor จาก row_starts (ตำแหน่งเริ่มต้นของแต่ละคำในลิสต์ตัวอักษรแบน)โค้ดตัวอย่างprint(Get the code point of every character in every wo

Total 9001 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:229/451  20-คอมพิวเตอร์/Page Goto:1 223 224 225 226 227 228 229 230 231 232 233 234 235