Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix data loader and feed dict #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions multi_frame_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
training_dataset = loader.load_tfrecord("/mnt/Bulk/commaai/monolithic_train.tfrecord", True)
validation_dataset = loader.load_tfrecord("/mnt/Bulk/speedchallenge/monolithic_test.tfrecord", False)

iterator = tf.data.Iterator.from_structure(training_dataset.output_types,
iterator_training = tf.data.Iterator.from_structure(training_dataset.output_types,
training_dataset.output_shapes)

iterator_validation = tf.data.Iterator.from_structure(validation_dataset.output_types,
validation_dataset.output_shapes)

training_init_op = iterator.make_initializer(training_dataset)
validation_init_op = iterator.make_initializer(validation_dataset)

frames, gt_pose, speeds = iterator.get_next()

# TODO: It is 2020, please use tensorflow 2.0 and tensorflow.keras coding style
training = tf.placeholder(tf.bool)
frames = tf.placeholder(tf.float, shape=[None, None, None, 3], name='frames')
gt_pose = tf.placeholder(tf.float, shape=[None, 6], name='gt_pose')
speeds = tf.placeholder(tf.float, shape=[None, 1], name='speeds')

conv5, (conv4, conv3, conv2, conv1) = nets.encoder_resnet(frames, None, training)
conv6 = tf.layers.conv2d(conv5, 512, (3, 3), strides=(2, 2), padding='same', activation=tf.nn.relu)
Expand Down Expand Up @@ -73,7 +78,9 @@
while True:
try:
i += 1
l, sl, _, _ = sess.run((loss, speed_loss, train_step, update_ops), {training: True})
frames, gt_pose, speeds = iterator_training.get_next()
l, sl, _, _ = sess.run((loss, speed_loss, train_step, update_ops),
{training: True, frames: frames, gt_pose: gt_pose, speeds: speeds})
losses.append(l)
speed_losses.append(sl)
if i % 100 == 0:
Expand All @@ -93,7 +100,8 @@
while True:
try:
i += 1
sl = sess.run(speed_loss, {training: False})
frames, gt_pose, speeds = iterator_validation.get_next()
sl = sess.run(speed_loss, {training: False, frames: frames, gt_pose: gt_pose, speeds: speeds})
speed_losses.append(sl)
except tf.errors.OutOfRangeError:
break
Expand Down