Last active
October 6, 2019 11:57
-
-
Save mrajchl/d2a9afcbbd361fab4cbd4beb557781a0 to your computer and use it in GitHub Desktop.
Load a tf feed_dict with data from memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load all data into memory | |
data = load_data(all_filenames, tf.estimator.ModeKeys.TRAIN, reader_params) | |
# Create placeholder variables and define their shapes (here, | |
# we input a volume image of size [128, 224, 244] and a single | |
# channel (i.e. greyscale): | |
x = tf.placeholder(reader_example_dtypes['features']['x'], | |
[None, 128, 224, 224, 1]) | |
y = tf.placeholder(reader_example_dtypes['labels']['y'], | |
[None, 1]) | |
# Create a tf.data.Dataset | |
dataset = tf.data.Dataset.from_tensor_slices((x, y)) | |
dataset = dataset.repeat(None) | |
dataset = dataset.batch(batch_size) | |
dataset = dataset.prefetch(1) | |
# Create an iterator | |
iterator = dataset.make_initializable_iterator() | |
nx = iterator.get_next() | |
with tf.train.MonitoredTrainingSession() as sess_dict: | |
sess_dict.run(iterator.initializer, | |
feed_dict={x: data['features'], y: data['labels']}) | |
for i in range(iterations): | |
# Get next features/labels pair | |
dict_batch_feat, dict_batch_lbl = sess_dict.run(nx) |
Because this is a gist code snippet, not a stand alone script. I'd refer to the actual tutorial: https://github.com/DLTK/DLTK/blob/master/examples/tutorials/01_reading_medical_images_in_tf.ipynb
thanks for your feedback
*Ali Nawaz*
*Software Engineer*
Cell: 03358043653
Address: University of Engineering and Technology Taxila.
…On Sun, Oct 6, 2019 at 3:44 PM Martin Rajchl ***@***.***> wrote:
Because this is a gist code snippet, not a stand alone script. I'd refer
to the actual tutorial:
https://github.com/DLTK/DLTK/blob/master/examples/tutorials/01_reading_medical_images_in_tf.ipynb
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/d2a9afcbbd361fab4cbd4beb557781a0?email_source=notifications&email_token=AI33XKXFFCPN5ACKFMVSY73QNG6SRA5CNFSM4I53MKW2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFZ7LQ#gistcomment-3047096>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI33XKW57EF7D6GAP5E73GDQNG6SRANCNFSM4I53MKWQ>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am facing below problem when i am running your code>? why is load_data is not defined in your program
load_data(all_filenames, tf.estimator.ModeKeys.TRAIN, reader_params)
NameError: name 'Loaddata' is not defined