当前位置: 首页 > news >正文

建立网站怎么做四年级的简短新闻播报

建立网站怎么做,四年级的简短新闻播报,开发定制软件,网站供应商代发怎么做TensorFlow 模型 张量、变量共同点:具有形状、类型、值等3个属性。 不同点:变量可被TensorFlow的自动求导机制求导,常被用于机器学习模型的参数。 tfrecord tensorflow定义的数据格式,一种二进制文件格式,用于保存…

TensorFlow

模型

张量、变量共同点:具有形状、类型、值等3个属性。

不同点:变量可被TensorFlow的自动求导机制求导,常被用于机器学习模型的参数。

tfrecord

tensorflow定义的数据格式,一种二进制文件格式,用于保存和读取图像和文本数据。tfrecord文件包含了tf.train.Example protobuf数据。It is designed for use with TensorFlow and is used throughout the higher-level APIS such as TFX.

基本结构与数据类型

tf.train.Example的数据结构是一个字典称为Features,其内部结构可从proto文件看出:

message Example {Features features = 1;
};message Features{map<string, Feature> featrue = 1;
};message Feature{oneof kind{BytesList bytes_list = 1;FloatList float_list = 2;Int64List int64_list = 3;}
};

数据类型Feature有3个,Int64、Bytes、Float;Int64存储bool、Enum、uint32、int32、int64、uint64,Bytes存储字符串、二进制,Float存储float(float32)和double(float64)。

文件格式即把数据参考字典结构做二进制数据的protobuf序列化,称为string。

def serialize_example(f1, f2, f3, f4):fts = {"feature0": _int64_feature(f1),"feature1": _int64_feature(f2),"feature2": _bytes_feature(f3),"feature3": _float_feature(f4),}m = tf.train.Example(features=tf.train.Features(feature=fts))return m.SerializeToString()
ps = serialize_example(3, True, b"goal", 0.999)
ex_proto = tf.train.Example.FromString(ps)

tf.train.Feature是被tf.train.Example兼容的。

import tensorflow as tf
def _bytes_feature(x):if isinstance(x, type(tf.constant(0))):x = x.numpy()return tf.train.Feature(bytes_list=tf.train.BytesList(value=[x]))
读写tfrecord文件
  1. 写文件
# Write the `tf.train.Example` observations to the file.
with tf.io.TFRecordWriter(filename) as writer:for i in range(n_observations):example = serialize_example(feature0[i], feature1[i], feature2[i], feature3[i])writer.write(example)
  1. 读文件
fn = "./Waymo.tfrecord"
rd = tf.data.TFRecordDataset(fn)
# 数据格式 
feature_description = {'feature0': tf.io.FixedLenFeature([], tf.int64, default_value=0),'feature1': tf.io.FixedLenFeature([], tf.int64, default_value=0),'feature2': tf.io.FixedLenFeature([], tf.string, default_value=''),'feature3': tf.io.FixedLenFeature([], tf.float32, default_value=0.0),
}def _parse_function(example_proto):# Parse the input `tf.train.Example` proto using the dictionary above.return tf.io.parse_single_example(example_proto, feature_description)parsed_dataset = raw_dataset.map(_parse_function)
for parsed_record in parsed_dataset.take(10):print(repr(parsed_record))
Waymo Open Dataset

采用tfrecord的数据协议,Dataset结构需参考
https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/dataset.proto
使用Python库waymo-open-dataset

#与tensorflow版本对应,如tf为2.3.0
pip3 install waymo-open-dataset-tf-2-3-0 --user
fn = ["/data/Waymo_training_segment-10023947602400723454_1120_000_1140_000_with_camera_labels.tfrecord"
]
dataset = tf.data.TFRecordDataset(fn)
for data in dataset.take(1000):frame = open_dataset.Frame()frame.ParseFromString(bytearray(data.numpy()))# plt.figure(figsize=(25, 20))# for index, image in enumerate(frame.images):#   show_camera_image(image, frame.camera_labels, [3, 3, index+1])# plt.show()ts = frame.timestamp_microsst_img = frame.images[0]for labels in frame.camera_labels:if labels.name == st_img.name:for label in labels.labels:x = int(label.box.center_x - 0.5 * label.box.length)y = int(label.box.center_y - 0.5 * label.box.width)width = int(label.box.length)height = int(label.box.width)

重复造轮子:用tf.io实现读取数据集。

问题

https://stackoverflow.com/questions/61166864/tensorflow-python-framework-ops-eagertensor-object-has-no-attribute-in-graph

Waymo Open Dataset文件解析格式,如何确定字典结构

raw_image_dataset = tf.data.TFRecordDataset('images.tfrecords')# Create a dictionary describing the features.
image_feature_description = {'height': tf.io.FixedLenFeature([], tf.int64),'width': tf.io.FixedLenFeature([], tf.int64),'depth': tf.io.FixedLenFeature([], tf.int64),'label': tf.io.FixedLenFeature([], tf.int64),'image_raw': tf.io.FixedLenFeature([], tf.string),
}def _parse_image_function(example_proto):# Parse the input tf.train.Example proto using the dictionary above.return tf.io.parse_single_example(example_proto, image_feature_description)parsed_image_dataset = raw_image_dataset.map(_parse_image_function)
http://www.15wanjia.com/news/13642.html

相关文章:

  • 做门户网站私活多少钱小网站搜什么关键词
  • 电脑如何下载网页视频文件冯耀宗seo博客
  • 第三方网站做app百度竞价排名收费标准
  • 万网 网站 ip现在搜索引擎哪个比百度好用
  • 有没有专业做效果图的网站seo是什么味
  • 子域名 做单独的网站商丘网络推广外包
  • 四川省城市建设培训中心 网站临沂seo顾问
  • 怎么免费做文学网站太原seo团队
  • 做心灵鸡汤网站栏目排版电商怎么做推广
  • 莱州网站建设seo排名优化首页
  • 中卫网站设计在哪里济南seo整站优化价格
  • 电子商务运营网站nba球队排名
  • wordpress 酒店预订郑州seo公司
  • 网站服务器部署指数平台
  • 可以做c语言任务的网站国内优秀网页设计赏析
  • 内网电脑做网站什么软件比百度搜索好
  • 北京做网站价格百度收录网址
  • 做时时彩网站微信平台有哪些热门关键词查询
  • 海南省住房城乡建设厅网站百度品牌专区
  • 做网站什么系统好新品推广活动方案
  • 淘宝网上购物商城seo营销外包公司
  • 做网站要钱嘛网上怎么推广产品
  • WordPress全站展示站长工具 seo综合查询
  • 微信营销策略有哪些seo排名软件价格
  • 餐饮网站建设方案免费发广告帖子的网站
  • 品牌搭建网站 官网sem推广是什么
  • 儿童 网站欣赏站长工具高清
  • 优质手机网站建设推荐中国十大关键词
  • 陕西网上注册公司流程视频重庆好的seo平台
  • 哪个网站可以做围棋作业全网推广的方式有哪些