Comments (2)
Try this tool from the tensorflow library.
tf.data.Dataset.from_generator
It will help use a generator function to load data in batches. I am providing a pseudocode example below.
# now the generator function
def data_generator(original_data:list=None,batch_size:int=10)->list:
# make sure the input data is not none
if original_data is None:
sys.exit("Input data invalid!")
#we need to run this forever
while 1:
# run a for loop to be able to fetch the data in batches
for batch in range(0,len(original_data),batch_size):
data = original_data[batch:batch+batch_size] # fetch bacthes
# I am not sure if this should be a numpy array
# but if it should, please use the appropriate type casting
# data = np.array(data).astype(np.float32) --> this is an example
# Find your appropriate casting and set it as such
# yield this current batch of data
yield data
"""
H0w to use this in your code
-------------------------------------------------
import tensorflow as tf
from data_generator import data_generator
custom_genenerator = data_generator(parameter_1, optional_param_2)
dataset = tf.data.Dataset.from_generator(custom_genenerator,(tf.float32, tf.int16))
iterator = dataset.make_one_shot_iterator()
x,y = iterator.get_next()
Check the following references for explanation
--------------------------------------------------
Ref:
https://sknadig.me/TensorFlow2.0-dataset/
https://www.tensorflow.org/api_docs/python/tf/data/Dataset#from_generator
"""
from c3d-tensorflow.
Try this tool from the tensorflow library.
tf.data.Dataset.from_generator
It will help use a generator function to load data in batches. I am providing a pseudocode example below.
# now the generator function def data_generator(original_data:list=None,batch_size:int=10)->list: # make sure the input data is not none if original_data is None: sys.exit("Input data invalid!") #we need to run this forever while 1: # run a for loop to be able to fetch the data in batches for batch in range(0,len(original_data),batch_size): data = original_data[batch:batch+batch_size] # fetch bacthes # I am not sure if this should be a numpy array # but if it should, please use the appropriate type casting # data = np.array(data).astype(np.float32) --> this is an example # Find your appropriate casting and set it as such # yield this current batch of data yield data """ H0w to use this in your code ------------------------------------------------- import tensorflow as tf from data_generator import data_generator custom_genenerator = data_generator(parameter_1, optional_param_2) dataset = tf.data.Dataset.from_generator(custom_genenerator,(tf.float32, tf.int16)) iterator = dataset.make_one_shot_iterator() x,y = iterator.get_next() Check the following references for explanation -------------------------------------------------- Ref: https://sknadig.me/TensorFlow2.0-dataset/ https://www.tensorflow.org/api_docs/python/tf/data/Dataset#from_generator """
Thanks for replying!But I am sorry I have not made progress yet.
Are there any codes about batch size that can be modified to reduce directly?
from c3d-tensorflow.
Related Issues (20)
- Error in trianing HOT 1
- Before about the reshape of dimension transform issues HOT 1
- ValueError: Cannot feed value of shape (11, 16, 160, 160, 3) for Tensor 'Placeholder:0', which has shape '(12, 16, 160, 160, 3)' HOT 1
- train_c3d_ucf101.py
- predict_c3d_ucf101.py
- very very big loss values
- Could you give me a list as example? HOT 1
- ValueError: setting an array element with a sequence. HOT 1
- What is the difference between clip accuracy and video accuracy?
- Train with last checkpoint
- ERROR when using conv3d
- about how to use .meta or index
- about preprocessing HOT 7
- UnboundLocalError: local variable 'img_datas' referenced before assignment HOT 2
- the accuracy is always 0 HOT 2
- overfitting HOT 1
- prototxt file for conv3d_deepnetA_sport1m_iter_1900000.caffemodel
- missunderstanding about .model file type HOT 1
- hou ge niubility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c3d-tensorflow.