当前位置:网站首页>Parallelization of accelerated training tf data. Dataset generator
Parallelization of accelerated training tf data. Dataset generator
2022-06-12 04:37:00 【u012804784】
High quality resource sharing
| Learning route guidance ( Click unlock ) | Knowledge orientation | Crowd positioning |
|---|---|---|
| 🧡 Python Actual wechat ordering applet 🧡 | Progressive class | This course is python flask+ Perfect combination of wechat applet , From the deployment of Tencent to the launch of the project , Create a full stack ordering system . |
| Python Quantitative trading practice | beginner | Take you hand in hand to create an easy to expand 、 More secure 、 More efficient quantitative trading system |
When dealing with large-scale data , Data cannot be fully loaded into memory , We usually use two options
- Use
tfrecords - Use
tf.data.Dataset.from_generator()
tfrecords Parallel use of The above has already been introduced , No more details here . If we don't want to generate tfrecord Intermediate document , Then the generator is what you need .
This paper mainly records that from_generator() Parallelization method of , stay tf.data in , Parallelization is mainly realized through map and num_parallel_calls Realization , But for some scenes , our generator() There is some processing logic in , It cannot be parallelized directly , The easiest way is to put generator() The logic in , Use map Realization .
tf.data.Dataset generator parallel
Yes generator() Complex logic in , We simplify it , That is, only some subscript value type operations are performed in the generator , take generator() In the processing section of py_function The parcel (wrapped) , And then call map Handle .
def func(i):
i = i.numpy() # Decoding from the EagerTensor object
x, y = your_processing_function(training_set[i])
return x, y
z = list(range(len(training_set))) # The index generator
dataset = tf.data.Dataset.from_generator(lambda: z, tf.uint8)
dataset = dataset.map(lambda i: tf.py_function(func=func,
inp=[i],
Tout=[tf.uint8,
tf.float32]
),
num_parallel_calls=tf.data.AUTOTUNE)
Because of implicit inference , Sometimes tensor Output shape It is unknown. , Need extra treatment
dataset = dataset.batch(8)
def \_fixup\_shape(x, y):
x.set_shape([None, None, None, nb_channels]) # n, h, w, c
y.set_shape([None, nb_classes]) # n, nb\_classes
return x, y
dataset = dataset.map(_fixup_shape)
tf.Tensor And tf.EagerTensor
Why tf.py_function, Let's start with tf.Tensor And tf.EagerTensor
EagerTensor It's real time , You can get its value at any time , That is, through numpy obtain
Tensor It's not real time , It is a component in a static diagram , Only when feeding data 、 The... Can only be obtained after the operation is completed Tensor Value ,
map Function operation of mapping in , And just tell dataset, Every time you take out a sample, you should do it first function Used after an operation , therefore function Is called at each iteration dataset Is called when , Belong to Static diagram logic
tensorflow.python.framework.ops.EagerTensor
tensorflow.python.framework.ops.Tensor
tf.py_function What role does it play here ?
Wraps a python function into a TensorFlow op that executes it eagerly.
Just now map Data static diagram logic , The default parameters are Tensor. and Use tf.py_function() After packing , The parameter becomes EagerTensor.
references
【2】https://blog.csdn.net/qq_27825451/article/details/105247211
【3】https://www.tensorflow.org/guide/data_performance#parallelizing_data_extraction
边栏推荐
- 2022 electrician (elementary) operation certificate examination question bank and online simulation examination
- Oracle paging query ~~rownum (line number)
- C# TaskFactory. Startnew method
- PostgreSQL age XID maintenance prevents the database from being read-only
- Epidemic data analysis platform work report [3] website deployment
- 2022 fusion welding and thermal cutting recurrent training question bank and simulation examination
- 疫情数据分析平台工作报告【6.5】疫情地图
- QT compile 45 graphic report of security video monitoring system
- mysqld: Can‘t create directory ‘D: oftinstall\mysql57 (Errcode: 2 - No such file or directory)
- How Windows installs multiple versions of MySQL and starts it at the same time
猜你喜欢

DS18B20 digital thermometer (I) electrical characteristics, power supply and wiring mode

Bearpi IOT lighting LED

L1-066 cat is liquid (5 points)

windows如何安装多个版本mysql,如何同时启动

Interview must ask: summary of ten classic sorting algorithms
![[wechat applet] the mobile terminal selects and publishes pictures](/img/9a/46bc4a7bf9b70d26b0e24fe02f747d.jpg)
[wechat applet] the mobile terminal selects and publishes pictures

WiFi module scheme of the wireless Internet of things, esp32-s3 chip technology, helps the equipment to be intelligent

Operation of simulated examination platform for theoretical question bank of G2 utility boiler stoker in 2022

Kill session? This cross domain authentication solution is really elegant!

Why should a redis cluster use a reverse proxy? Just read this one
随机推荐
[SC] OpenService FAILED 5: Access is denied.
L1-066 cat is liquid (5 points)
Oracle's instr()
Esp32c3 remote serial port
WiFi module scheme of the wireless Internet of things, esp32-s3 chip technology, helps the equipment to be intelligent
[software tool] [original] tutorial on using VOC dataset class alias batch modification tool
[fpga+fft] design and implementation of FFT frequency meter based on FPGA
Daily practice (28): balance binary tree
Encapsulation manuelle d'un foreach et d'une carte
2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)
2022 low voltage electrician test questions and simulation test
The third "World War" - chip defense, smokeless battlefield!
Detailed explanation of software testing process
Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application
Legendary biological car-t has been approved by FDA, becoming the first domestic cell therapy product to successfully go to sea
In the era of smart retail, Weimeng reshapes the value of "shopping guide"
How to make datasets, train them into models and deploy them based on yolov5
JWT學習與使用
Please calculate the value of the following function recursively: PX (x, n) =x-x^2 +x^3- x^4+... (-1) n-1) (xn) n > 0 * * input format requirements: "%lf%d" prompt: "enter X and n:"
Call reminder