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

Update eidetic_3d_lstm_net.py #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions src/models/eidetic_3d_lstm_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def rnn(images, real_input_flag, num_layers, num_hidden, configs):

memory = zero_state

with tf.variable_scope('generator'):
with tf.compat.v1.variable_scope('generator'):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Compat flags added
  • Need TF2.2 upgradation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @Sgsouham

input_list = []
reuse = False
for time_step in range(window_length - 1):
input_list.append(
tf.zeros([batch_size, ims_width, ims_height, output_channels]))

for time_step in range(total_length - 1):
with tf.variable_scope('e3d-lstm', reuse=reuse):
with tf.compat.v1.variable_scope('e3d-lstm', reuse=reuse):
if time_step < input_length:
input_frm = images[:, time_step]
else:
Expand All @@ -76,7 +76,7 @@ def rnn(images, real_input_flag, num_layers, num_hidden, configs):

if time_step % (window_length - window_stride) == 0:
input_frm = tf.stack(input_list[time_step:])
input_frm = tf.transpose(input_frm, [1, 0, 2, 3, 4])
input_frm = tf.transpose(a=input_frm, perm=[1, 0, 2, 3, 4])

for i in range(num_layers):
if time_step == 0:
Expand All @@ -90,17 +90,17 @@ def rnn(images, real_input_flag, num_layers, num_hidden, configs):
hidden[i], cell[i], memory = lstm_layer[i](
inputs, hidden[i], cell[i], memory, c_history[i])

x_gen = tf.layers.conv3d(hidden[num_layers - 1], output_channels,
x_gen = tf.compat.v1.layers.conv3d(hidden[num_layers - 1], output_channels,
[window_length, 1, 1], [window_length, 1, 1],
'same')
x_gen = tf.squeeze(x_gen)
gen_images.append(x_gen)
reuse = True

gen_images = tf.stack(gen_images)
gen_images = tf.transpose(gen_images, [1, 0, 2, 3, 4])
gen_images = tf.transpose(a=gen_images, perm=[1, 0, 2, 3, 4])
loss = tf.nn.l2_loss(gen_images - images[:, 1:])
loss += tf.reduce_sum(tf.abs(gen_images - images[:, 1:]))
loss += tf.reduce_sum(input_tensor=tf.abs(gen_images - images[:, 1:]))

out_len = total_length - input_length
out_ims = gen_images[:, -out_len:]
Expand Down