如果onPostExecute方法的语句没有执行

时间:2016-03-27 09:56:15

标签: php android mysql

如果来自服务器的响应等于“连接成功......登录成功”,我想转移到另一个活动。在我的PHP代码中,我回应“连接成功......登录成功”以获取由doInbackground()接收的正确细节。但每次只执行其他部分。 整个代码是AsyncTask的一部分......在这里

def batch_sample_with_temperature(a, temperature=1.0):
'''this function is like sample_with_temperature except it can handle batch input a of [batch_size x logits] 
    this function takes logits input, and produces a specific number from the array. This is all done on the gpu
    because this function uses tensorflow
    As you increase the temperature, you will get more diversified output but with more errors (usually gramatical if you're 
        doing text)
args: 
    Logits -- this must be a 2d array [batch_size x logits]
    Temperature -- how much variance you want in output
returns:
    Selected number from distribution
'''

'''
Equation can be found here: https://en.wikipedia.org/wiki/Softmax_function (under reinforcement learning)
    Karpathy did it here as well: https://github.com/karpathy/char-rnn/blob/4297a9bf69726823d944ad971555e91204f12ca8/sample.lua'''
'''a is [batch_size x logits]'''
with tf.op_scope([a,temperature], "batch_sample_with_temperature"):

    exponent_raised = tf.exp(tf.div(a, temperature)) #start by reduction of temperature, and get rid of negative numbers with exponent
    matrix_X = tf.div(exponent_raised, tf.reduce_sum(exponent_raised, reduction_indices = 1)) #this will yield probabilities!
    matrix_U = tf.random_uniform(tf.shape(a), minval = 0, maxval = 1)
    final_number = tf.argmax(tf.sub(matrix_X, matrix_U), dimension = 1) #you want dimension = 1 because you are argmaxing across rows.

return final_number

String doInBacground(String ... params)中的代码就是这个

@Override
protected void onPostExecute(String s) {

    String s1=s.toString();
    String ls= "Connection success...Login Success";
    String rs= "Connection success...Registered Successfully";
    loading.dismiss();
        if(s1.equals(ls))
        {

            Intent intent = new Intent(ctx,MainActivity.class);
          //  intent.putExtra("USER_NAME",login_name);
            ctx.startActivity(intent);

        }


   /*     else{
            Toast.makeText(ctx,result,Toast.LENGTH_LONG).show();
        }
    }
    else if(method.equals("register")) {
   */
        else if(s1.equals(rs)){
            Intent intent = new Intent(ctx,Login.class);
            ctx.startActivity(intent);
        }
        else{
            Toast.makeText(ctx,s1,Toast.LENGTH_LONG).show();

        }
   // }
}

}

0 个答案:

没有答案