tf.eye()
import tensorflow as tf print(tf.eye(2)) batch_identity = tf.eye(2, batch_shape=[3]) print(batch_identity) print(tf.eye(2, num_columns=3))
E:\新脚本主文件夹\训练测试项目\venv3\Scripts\python.exe E:/新脚本主文件夹/训练测试项目/test_tf/eye.py 2020-12-22 15:05:42.797079: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found 2020-12-22 15:05:42.797448: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2020-12-22 15:05:47.973319: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll 2020-12-22 15:05:48.640457: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: pciBusID: 0000:06:00.0 name: Quadro M500M computeCapability: 5.0 coreClock: 1.124GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 14.92GiB/s 2020-12-22 15:05:48.648267: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found 2020-12-22 15:05:48.659902: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll 2020-12-22 15:05:48.668387: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll 2020-12-22 15:05:48.671699: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll 2020-12-22 15:05:48.681127: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll 2020-12-22 15:05:48.688573: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll 2020-12-22 15:05:48.695409: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found 2020-12-22 15:05:48.695869: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... 2020-12-22 15:05:48.697503: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2020-12-22 15:05:48.719109: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1fe75c84fa0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-12-22 15:05:48.721500: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2020-12-22 15:05:48.721963: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-12-22 15:05:48.722528: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] tf.Tensor( [[1. 0.] [0. 1.]], shape=(2, 2), dtype=float32) tf.Tensor( [[[1. 0.] [0. 1.]] [[1. 0.] [0. 1.]] [[1. 0.] [0. 1.]]], shape=(3, 2, 2), dtype=float32) tf.Tensor( [[1. 0. 0.] [0. 1. 0.]], shape=(2, 3), dtype=float32) Process finished with exit code 0