一、课件
二、课后习题
三、答案
1.
import os
def scan_image_file(path):
result = {}
traverse(path, result)
return result
def traverse(path, pathsDic):
tempFile = []
tempName = ''
filePath = [os.path.join(path, f) for f in os.listdir(path)]
for itemPath in filePath:
if os.path.isdir(itemPath):
traverse(itemPath, pathsDic)
elif os.path.isfile(itemPath):
tempFile.append(itemPath.split("\\")[-1])
tempName = itemPath.split("\\")[-2]
else:
print("未知,出现错误")
pathsDic[tempName] = tempFile
return tempName, tempFile
if __name__ == "__main__":
PATH = "data"
pathsDic = scan_image_file(PATH)
print(pathsDic)
2.
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
a = tf.constant([[2, -1], [0, 3], [-5, 4]])
b = tf.constant([[1, 0, 1, 0], [0, 1, 0, -1]])
c = tf.matmul(a, b)
d = tf.transpose(b)
with tf.Session() as sess:
print(sess.run(c))
print(sess.run(d))
Comments | NOTHING