tensorflow如何从不同的名称范围分组操作?

时间:2016-06-27 03:43:05

标签: tensorflow

例如:

<?php
session_start();
include_once("db.php");

$simname = $_REQUEST["id"];
$sim_num = $_REQUEST["num"];
$name = $_SESSION['sasi_ad_name'];
$id = $_SESSION['sasi_ad_id'];

$query5=mysql_query("SELECT id, sim_number, phone_num, status, plan, add_on, features, Delear, Sub_Delear, T_C, sim_type FROM sims where sim_number='$sim_num' and sim_type='$simname'");

$query6=mysql_fetch_array($query5);
$delarname = $query6['Delear'];

$query7=mysql_query("SELECT id, name, Email, Phone, password, status, address, own, Identity_proof FROM adminusers WHERE name='$delarname'");

$query8=mysql_fetch_array($query7);
$demail = $query8['Email'];

$phone = $query8['Phone'];
$query2=mysql_query("SELECT id, name, Email, Phone, password, status, address, own, Identity_proof FROM adminusers WHERE status='0'");

$query3=mysql_fetch_array($query2);
$email = $query3['Email'];


if($_POST['submit'])
{
$subject="Activation Conformation SIM'";

$ip=$_SERVER['REMOTE_ADDR'];
$to  = $demail . ', '; // note the comma
$to .= $email;


// message

$message =  "<table align='left'>
        <tr height=20>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Delear Name : </b> $delarname</td>
        </tr>
        <tr>
            <td><b>SIM Number : </b> $sim_num</td>
        </tr>
        <tr>
            <td><b>SIM Type : </b> $simname </td>
        </tr>
        <tr>
            <td><b>Phone No : </b> $phone</td>
        </tr>

        <tr height=10>
                <td>&nbsp;</td>
        </tr>
        <tr height=10>
                <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Customer IP Address : </b> $ip</td>
        </tr>
        <tr height=20>
            <td>&nbsp;</td>
        </tr>
    </table> " ;


// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Olpur <support@olpur.com>, Vegaitindia pvt ltd <contact@olpur.com>' . "\r\n";
$headers .= 'From: Support Query <support@olpur.com>' . "\r\n";
$headers .= 'Cc: andesasi1222@gmail' . "\r\n";
$headers .= 'Bcc: andesasi1222@gmail' . "\r\n";

// Mail it
$a = mail($to, $subject, $message, $headers);
if($a)
  {


        echo "<script> alert('THANK YOU…!! OUR TEAM WOULD SHORTLY CONTACT YOU'); window.location='../';</script>";

  }else{

        echo "<script> alert('Fail to save your information. Please re-enter your information'); window.location='index.php';</script>";
  }
}
?>

然后我想将for s in xrange(2): with tf.name_scope('myscope_%d % s) as scope: some ops result = a op myscope_0/result组合在一起,例如:

myscope_1/result

怎么做?上面的行是不正确的。

1 个答案:

答案 0 :(得分:2)

您可以这样做:

graph = tf.get_default_graph()

var = tf.Variable(0)

for s in xrange(2):
    with tf.name_scope('myscope_%d' % s):
        op = var.assign_add(s + 1)

all_operations = [graph.get_operation_by_name('myscope_%d/AssignAdd' % s) for s in range(2)]
all_op = tf.group(*all_operations)

在此,我将变量var的操作组合在一起(第一个将增加1,第二个增加2)。

你可以测试一下:

sess = tf.Session()
sess.run(tf.initialize_all_variables())
print sess.run(var)  # prints 0
sess.run(all_op)
print sess.run(var)  # prints 3