上传文件至 /
This commit is contained in:
7
.py.txt
Normal file
7
.py.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import numpy as np
|
||||||
|
img = np.array([
|
||||||
|
[255, 255, 0, 0 ],
|
||||||
|
[255, 255, 0, 0 ],
|
||||||
|
[0, 0, 255, 255],
|
||||||
|
[0, 0, 255, 255]
|
||||||
|
], dtype=np.uint8)
|
||||||
10
import numpy as np.py
Normal file
10
import numpy as np.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import numpy as np
|
||||||
|
|
||||||
|
image = np.array([
|
||||||
|
[100, 150, 200],
|
||||||
|
[80, 120, 180],
|
||||||
|
[60, 90, 140]
|
||||||
|
], dtype=np.uint8)
|
||||||
|
|
||||||
|
print("原图:")
|
||||||
|
print(image)
|
||||||
17
import numpy as np3.py
Normal file
17
import numpy as np3.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import numpy as np
|
||||||
|
vocab = ["Python", "学习", "数据", "人工智能", "编程"]
|
||||||
|
doc1 = "Python学习编程"
|
||||||
|
doc2 = "Python人工智能数据"
|
||||||
|
|
||||||
|
def text_to_vector(text, vocab):
|
||||||
|
words = text.split()
|
||||||
|
vector = np.zeros(len(vocab))
|
||||||
|
for i, word in enumerate(vocab):
|
||||||
|
vector[i] = words.count(word)
|
||||||
|
return vector
|
||||||
|
|
||||||
|
v1 = text_to_vector(doc1, vocab)
|
||||||
|
v2 = text_to_vector(doc2, vocab)
|
||||||
|
|
||||||
|
print("doc1向量:", v1)
|
||||||
|
print("doc2向量:", v2)
|
||||||
Reference in New Issue
Block a user