Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Resolve Running Session Failed Issue for Python Chatbot App Using Tensorflow

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 483
    Answer it

    This is where I'm getting the error. I just want to ask what should I do, to make this code running. I'm building a chatbot using tensorflow. And mostly the error is encountered in the if-else statements. So please have a look at it. And let me know asap, Thank you :)

     

    def run_step(sess, model, encoder_inputs, decoder_inputs, decoder_masks, bucket_id, forward_only):
      """ Run one step in training.
      @forward_only: boolean value to decide whether a backward path should be created
      forward_only is set to True when you just want to evaluate on the test set,
      or when you want to the bot to be in chat mode. """
      encoder_size, decoder_size = config.BUCKETS[bucket_id]
      _assert_lengths(encoder_size, decoder_size, encoder_inputs, decoder_inputs, decoder_masks)
    
      # input feed: encoder inputs, decoder inputs, target_weights, as provided.
      input_feed = {}
      for step in range(encoder_size):
        input_feed[model.encoder_inputs[step].name] = encoder_inputs[step]
      for step in range(decoder_size):
        input_feed[model.decoder_inputs[step].name] = decoder_inputs[step]
        input_feed[model.decoder_masks[step].name] = decoder_masks[step]
    
      last_target = model.decoder_inputs[decoder_size].name
      input_feed[last_target] = np.zeros([model.batch_size], dtype=np.int32)
    
      # output feed: depends on whether we do a backward step or not.
      if not forward_only:
        output_feed = [model.train_ops[bucket_id], # update op that does SGD.
               model.gradient_norms[bucket_id], # gradient norm.
               model.losses[bucket_id]] # loss for this batch.
      else:
        output_feed = [model.losses[bucket_id]] # loss for this batch.
        for step in range(decoder_size): # output logits.
          output_feed.append(model.outputs[bucket_id][step])
    
      outputs = sess.run(output_feed, input_feed)
      if not forward_only:
        return outputs[1], outputs[2], None # Gradient norm, loss, no outputs.
      else:
        return None, outputs[0], outputs[1:] # No gradient norm, loss, outputs.

     

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: