当前位置:网站首页>TF使用constant生成数据

TF使用constant生成数据

2022-08-09 21:35:00 phac123

简介

TF指定了生成的数据类型,最后生成的数据就是指定的类型;如果TF中使用constant没有指定生成什么数据,如果是1,4这样的整数,那么默认的数据类型为 tf.int32.

实现与分析

One

import tensorflow as tf

a = tf.constant([1, 5], dtype = tf.int64)
print("a: ", a)
print("a.dtype: ", a.dtype)
print("a.shape: ", a.shape)

在这里插入图片描述

Two:默认

import tensorflow as tf

a = tf.constant([1, 5])
print("a: ", a)
print("a.dtype: ", a.dtype)
print("a.shape: ", a.shape)

在这里插入图片描述
three

import tensorflow as tf

a = tf.constant([1, 5], dtype = tf.float32)
print("a: ", a)
print("a.dtype: ", a.dtype)
print("a.shape: ", a.shape)

在这里插入图片描述

原网站

版权声明
本文为[phac123]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_42596275/article/details/126248002