Giter Club home page Giter Club logo

Comments (3)

pc2752 avatar pc2752 commented on September 16, 2024

Hi,

Could you provide more details about which function of which file you are changing?

from wgansing.

liuhuang31 avatar liuhuang31 commented on September 16, 2024

Hi,
the change file is 'modules_tf.py'.
The code i added is below.

output = encoder_decoder_archi_gan(inputs, is_train)
output = tf.tanh(tf.layers.batch_normalization(tf.layers.dense(output, config.output_features, name = "Fu_F", kernel_initializer=tf.random_normal_initializer(stddev=0.02)), training = is_train, name = "bn_fu_out"))

output = tf.squeeze(output)

# add lstm layer
lstm_cell = tf.contrib.rnn.BasicLSTMCell(64, forget_bias=1.0, state_is_tuple=True)
init_state = lstm_cell.zero_state(batch_size=config.batch_size, dtype=tf.float32)
lstm_out, final_state = tf.nn.dynamic_rnn(lstm_cell, output, initial_state=init_state, time_major=False)
lstm_out = tf.tanh(tf.layers.batch_normalization(tf.layers.dense(lstm_out, config.output_features, name = "T_GRU", kernel_initializer=tf.random_normal_initializer(stddev=0.02)), training=is_train, name = "gru_out"))

return lstm_out

from wgansing.

pc2752 avatar pc2752 commented on September 16, 2024

I would define an LSTM function as follows:

def bi_static_stacked_RNN(x, scope='RNN', lstm_size = config.lstm_size):
"""
Input and output in batch major format
"""
with tf.variable_scope(scope):
x = tf.unstack(x, config.max_phr_len, 1)

    output = x
    num_layer = 2
    # for n in range(num_layer):
    lstm_fw = tf.nn.rnn_cell.LSTMCell(lstm_size, state_is_tuple=True)
    lstm_bw = tf.nn.rnn_cell.LSTMCell(lstm_size, state_is_tuple=True)

    _initial_state_fw = lstm_fw.zero_state(config.batch_size, tf.float32)
    _initial_state_bw = lstm_bw.zero_state(config.batch_size, tf.float32)

    output, _state1, _state2 = tf.contrib.rnn.static_bidirectional_rnn(lstm_fw, lstm_bw, output, 
                                              initial_state_fw=_initial_state_fw,
                                              initial_state_bw=_initial_state_bw, 
                                              scope='BLSTM_'+scope)
    output = tf.stack(output)
    output_fw = output[0]
    output_bw = output[1]
    output = tf.transpose(output, [1,0,2])

    return output

And then pass the output to it as:
output = bi_static_stacked_RNN(output, scope = "scope")

from wgansing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.