MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / create_model

Function create_model

chatbotv4/translate.py:102–124  ·  view source on GitHub ↗

Create translation model and initialize or load parameters in session.

(session, forward_only)

Source from the content-addressed store, hash-verified

100
101
102def create_model(session, forward_only):
103 """Create translation model and initialize or load parameters in session."""
104 dtype = tf.float32
105 model = seq2seq_model.Seq2SeqModel(
106 FLAGS.input_vocab_size,
107 FLAGS.output_vocab_size,
108 _buckets,
109 FLAGS.size,
110 FLAGS.num_layers,
111 FLAGS.max_gradient_norm,
112 FLAGS.batch_size,
113 FLAGS.learning_rate,
114 FLAGS.learning_rate_decay_factor,
115 forward_only=forward_only,
116 dtype=dtype)
117 ckpt = tf.train.get_checkpoint_state(FLAGS.train_dir)
118 if ckpt and tf.train.checkpoint_exists(ckpt.model_checkpoint_path):
119 print("Reading model parameters from %s" % ckpt.model_checkpoint_path)
120 model.saver.restore(session, ckpt.model_checkpoint_path)
121 else:
122 print("Created model with fresh parameters.")
123 session.run(tf.global_variables_initializer())
124 return model
125
126
127def train():

Callers 2

trainFunction · 0.70
decodeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected