当前位置: 首页>>代码示例>>Python>>正文


Python flags.FLAGS属性代码示例

本文整理汇总了Python中tensorflow.python.platform.flags.FLAGS属性的典型用法代码示例。如果您正苦于以下问题:Python flags.FLAGS属性的具体用法?Python flags.FLAGS怎么用?Python flags.FLAGS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在tensorflow.python.platform.flags的用法示例。


在下文中一共展示了flags.FLAGS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_mparams

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def create_mparams():
  return {
      'conv_tower_fn':
      model.ConvTowerParams(final_endpoint=FLAGS.final_endpoint),
      'sequence_logit_fn':
      model.SequenceLogitsParams(
          use_attention=FLAGS.use_attention,
          use_autoregression=FLAGS.use_autoregression,
          num_lstm_units=FLAGS.num_lstm_units,
          weight_decay=FLAGS.weight_decay,
          lstm_state_clip_value=FLAGS.lstm_state_clip_value),
      'sequence_loss_fn':
      model.SequenceLossParams(
          label_smoothing=FLAGS.label_smoothing,
          ignore_nulls=FLAGS.ignore_nulls,
          average_across_timesteps=FLAGS.average_across_timesteps)
  } 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:common_flags.py

示例2: get_args

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def get_args():
  navtask = nec.nav_env_base_config()
  navtask.task_params.type = 'rng_rejection_sampling_many'
  navtask.task_params.rejection_sampling_M = 2000
  navtask.task_params.min_dist = 10
  sz = FLAGS.image_size
  navtask.camera_param.fov = FLAGS.fov
  navtask.camera_param.height = sz
  navtask.camera_param.width = sz
  navtask.task_params.img_height = sz
  navtask.task_params.img_width = sz
  
  # navtask.task_params.semantic_task.class_map_names = ['chair', 'door', 'table']
  # navtask.task_params.type = 'to_nearest_obj_acc'
  
  logging.info('navtask: %s', navtask)
  return navtask 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:script_env_vis.py

示例3: test

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def test(model, dataset, sess, inner_lr):
    # for each batch
    eval_valid_loss_list = []
    for i in range(int(FLAGS.test_total_num_tasks/FLAGS.num_tasks)):
        # load data
        [follow_x, _, valid_x,
         follow_y, _, valid_y] = dataset.generate_batch(is_training=False,
                                                        batch_idx=i * FLAGS.num_tasks,
                                                        inc_follow=True)

        # set input
        feed_in = OrderedDict()
        feed_in[model.follow_lr] = inner_lr
        feed_in[model.follow_x] = follow_x
        feed_in[model.follow_y] = follow_y
        feed_in[model.valid_x] = valid_x
        feed_in[model.valid_y] = valid_y

        # result
        eval_valid_loss_list.append(sess.run(model.eval_valid_loss, feed_in))

    # aggregate results
    eval_valid_loss_list = np.array(eval_valid_loss_list)
    eval_valid_loss_mean = np.mean(eval_valid_loss_list, axis=0)
    return eval_valid_loss_mean 
开发者ID:jsikyoon,项目名称:bmaml,代码行数:27,代码来源:bmaml_main.py

示例4: test

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def test(model, dataset, sess, inner_lr):
    # for each batch
    eval_valid_loss_list = []
    for i in range(int(FLAGS.test_total_num_tasks/FLAGS.num_tasks)):
        # load data
        [train_x, valid_x,
         train_y, valid_y] = dataset.generate_batch(is_training=False,
                                                    batch_idx=i * FLAGS.num_tasks)

        # set input
        feed_in = OrderedDict()
        feed_in[model.in_lr] = inner_lr
        feed_in[model.train_x] = train_x
        feed_in[model.valid_x] = valid_x
        feed_in[model.train_y] = train_y
        feed_in[model.valid_y] = valid_y

        # result
        eval_valid_loss_list.append(sess.run(model.eval_valid_loss, feed_in))

    # aggregate results
    eval_valid_loss_list = np.array(eval_valid_loss_list)
    eval_valid_loss_mean = np.mean(eval_valid_loss_list, axis=0)
    return eval_valid_loss_mean 
开发者ID:jsikyoon,项目名称:bmaml,代码行数:26,代码来源:emaml_main.py

示例5: kernel

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def kernel(self, particle_tensor, h=-1):
        euclidean_dists = tf_utils.pdist(particle_tensor)
        pairwise_dists = tf_utils.squareform(euclidean_dists) ** 2

        if h == -1:
            if FLAGS.kernel == 'org':
                mean_dist = tf_utils.median(pairwise_dists)  # tf.reduce_mean(euclidean_dists) ** 2
                h = mean_dist / math.log(self.num_particles)
                h = tf.stop_gradient(h)
            elif FLAGS.kernel == 'med':
                mean_dist = tf_utils.median(euclidean_dists) ** 2
                h = mean_dist / math.log(self.num_particles)
                h = tf.stop_gradient(h)
            else:
                mean_dist = tf.reduce_mean(euclidean_dists) ** 2
                h = mean_dist / math.log(self.num_particles)

        kernel_matrix = tf.exp(-pairwise_dists / h)
        kernel_sum = tf.reduce_sum(kernel_matrix, axis=1, keep_dims=True)
        grad_kernel = -tf.matmul(kernel_matrix, particle_tensor)
        grad_kernel += particle_tensor * kernel_sum
        grad_kernel /= h
        return kernel_matrix, grad_kernel, h 
开发者ID:jsikyoon,项目名称:bmaml,代码行数:25,代码来源:bmaml.py

示例6: attack_single

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def attack_single(self, img, target):
        """
        Run the attack on a single image and label
        """

        # the previous image
        prev = np.copy(img).reshape((1, FLAGS.IMAGE_ROWS, FLAGS.IMAGE_COLS, FLAGS.NUM_CHANNELS))
        tau = self.EPS
        const = self.INITIAL_CONST

        res = self.grad([np.copy(img)], [target], np.copy(prev), tau, const)

        if res is None:
            # the attack failed, we return this as our final answer
            return prev

        scores, origscores, nimg, const = res
        prev = nimg
        return prev 
开发者ID:sunblaze-ucb,项目名称:blackbox-attacks,代码行数:21,代码来源:carlini_li_ens.py

示例7: modelA

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def modelA():
    model = Sequential()
    model.add(Conv2D(64, (5, 5),
                            padding='valid'))
    model.add(Activation('relu'))

    model.add(Conv2D(64, (5, 5)))
    model.add(Activation('relu'))

    model.add(Dropout(0.25))

    model.add(Flatten())
    model.add(Dense(128))
    model.add(Activation('relu'))

    model.add(Dropout(0.5))
    model.add(Dense(FLAGS.NUM_CLASSES))
    return model 
开发者ID:sunblaze-ucb,项目名称:blackbox-attacks,代码行数:20,代码来源:mnist.py

示例8: modelB

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def modelB():
    model = Sequential()
    model.add(Dropout(0.2, input_shape=(FLAGS.IMAGE_ROWS,
                                        FLAGS.IMAGE_COLS,
                                        FLAGS.NUM_CHANNELS)))
    model.add(Convolution2D(64, 8, 8,
                            subsample=(2, 2),
                            border_mode='same'))
    model.add(Activation('relu'))

    model.add(Convolution2D(128, 6, 6,
                            subsample=(2, 2),
                            border_mode='valid'))
    model.add(Activation('relu'))

    model.add(Convolution2D(128, 5, 5,
                            subsample=(1, 1)))
    model.add(Activation('relu'))

    model.add(Dropout(0.5))

    model.add(Flatten())
    model.add(Dense(FLAGS.NUM_CLASSES))
    return model 
开发者ID:sunblaze-ucb,项目名称:blackbox-attacks,代码行数:26,代码来源:mnist.py

示例9: modelC

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def modelC():
    model = Sequential()
    model.add(Convolution2D(128, 3, 3,
                            border_mode='valid',
                            input_shape=(FLAGS.IMAGE_ROWS,
                                         FLAGS.IMAGE_COLS,
                                         FLAGS.NUM_CHANNELS)))
    model.add(Activation('relu'))

    model.add(Convolution2D(64, 3, 3))
    model.add(Activation('relu'))

    model.add(Dropout(0.25))

    model.add(Flatten())
    model.add(Dense(128))
    model.add(Activation('relu'))

    model.add(Dropout(0.5))
    model.add(Dense(FLAGS.NUM_CLASSES))
    return model 
开发者ID:sunblaze-ucb,项目名称:blackbox-attacks,代码行数:23,代码来源:mnist.py

示例10: modelF

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def modelF():
    model = Sequential()

    model.add(Convolution2D(32, 3, 3,
                            border_mode='valid',
                            input_shape=(FLAGS.IMAGE_ROWS,
                                         FLAGS.IMAGE_COLS,
                                         FLAGS.NUM_CHANNELS)))
    model.add(Activation('relu'))

    model.add(MaxPooling2D(pool_size=(2, 2)))

    model.add(Convolution2D(64, 3, 3))
    model.add(Activation('relu'))

    model.add(MaxPooling2D(pool_size=(2, 2)))

    model.add(Flatten())
    model.add(Dense(1024))
    model.add(Activation('relu'))

    model.add(Dense(FLAGS.NUM_CLASSES))

    return model 
开发者ID:sunblaze-ucb,项目名称:blackbox-attacks,代码行数:26,代码来源:mnist.py

示例11: forward_conv

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def forward_conv(self, inp, weights, prefix, reuse=False, scope=''):
        # reuse is for the normalization parameters.
        channels = self.channels
        inp = tf.reshape(inp, [-1, self.img_size, self.img_size, channels])

        hidden1 = conv_block(inp, weights['conv1'], weights['b1'], reuse, scope+'0')
        hidden2 = conv_block(hidden1, weights['conv2'], weights['b2'], reuse, scope+'1')
        hidden3 = conv_block(hidden2, weights['conv3'], weights['b3'], reuse, scope+'2')
        hidden4 = conv_block(hidden3, weights['conv4'], weights['b4'], reuse, scope+'3')
        if FLAGS.dataset == 'miniimagenet' or FLAGS.dataset == 'celeba' or FLAGS.dataset == 'imagenet':
            # last hidden layer is 6x6x64-ish, reshape to a vector
            hidden4 = tf.reshape(hidden4, [-1, np.prod([int(dim) for dim in hidden4.get_shape()[1:]])])
        else:
            hidden4 = tf.reduce_mean(hidden4, [1, 2])

        logits = tf.matmul(hidden4, weights['w5']) + weights['b5']

        if 'val' in prefix:
            logits = tf.gather(logits, tf.range(self.dim_output_val), axis=1)
        return logits 
开发者ID:kylehkhsu,项目名称:cactus-maml,代码行数:22,代码来源:maml.py

示例12: run

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def run(main=None, argv=None):
  """Runs the program with an optional 'main' function and 'argv' list."""
  f = flags.FLAGS

  # Extract the args from the optional `argv` list.
  args = argv[1:] if argv else None

  # Parse the known flags from that list, or from the command
  # line otherwise.
  # pylint: disable=protected-access
  flags_passthrough = f._parse_flags(args=args)
  # pylint: enable=protected-access

  main = main or _sys.modules['__main__'].main

  # Call the main function, passing through any arguments
  # to the final program.
  _sys.exit(main(_sys.argv[:1] + flags_passthrough)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:app.py

示例13: create_tb_app

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def create_tb_app(plugins):
  """Read the flags, and create a TensorBoard WSGI application.

  Args:
    plugins: A list of plugins for TensorBoard to initialize.

  Raises:
    ValueError: if a logdir is not specified.

  Returns:
    A new TensorBoard WSGI application.
  """
  if not FLAGS.logdir:
    raise ValueError('A logdir must be specified. Run `tensorboard --help` for '
                     'details and examples.')

  logdir = os.path.expanduser(FLAGS.logdir)
  return application.standard_tensorboard_wsgi(
      logdir=logdir,
      purge_orphaned_data=FLAGS.purge_orphaned_data,
      reload_interval=FLAGS.reload_interval,
      plugins=plugins) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:tensorboard.py

示例14: forward_conv

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def forward_conv(self, inp, weights, reuse=False, scope=''):
        # reuse is for the normalization parameters.
        channels = self.channels
        inp = tf.reshape(inp, [-1, self.img_size, self.img_size, channels])

        hidden1 = conv_block(inp, weights['conv1'], weights['b1'], reuse, scope+'0')
        hidden2 = conv_block(hidden1, weights['conv2'], weights['b2'], reuse, scope+'1')
        hidden3 = conv_block(hidden2, weights['conv3'], weights['b3'], reuse, scope+'2')
        hidden4 = conv_block(hidden3, weights['conv4'], weights['b4'], reuse, scope+'3')
        if FLAGS.datasource == 'miniimagenet':
            # last hidden layer is 6x6x64-ish, reshape to a vector
            hidden4 = tf.reshape(hidden4, [-1, np.prod([int(dim) for dim in hidden4.get_shape()[1:]])])
        else:
            hidden4 = tf.reduce_mean(hidden4, [1, 2])

        return tf.matmul(hidden4, weights['w5']) + weights['b5'] 
开发者ID:cbfinn,项目名称:maml,代码行数:18,代码来源:maml.py

示例15: jacobian_graph

# 需要导入模块: from tensorflow.python.platform import flags [as 别名]
# 或者: from tensorflow.python.platform.flags import FLAGS [as 别名]
def jacobian_graph(predictions, x):
    """
    Create the Jacobian graph to be ran later in a TF session
    :param predictions: the model's symbolic output (linear output, pre-softmax)
    :param x: the input placeholder
    :return:
    """
    # This function will return a list of TF gradients
    list_derivatives = []

    # Define the TF graph elements to compute our derivatives for each class
    for class_ind in xrange(FLAGS.nb_classes):
        derivatives, = tf.gradients(predictions[:, class_ind], x)
        list_derivatives.append(derivatives)

    return list_derivatives 
开发者ID:YingzhenLi,项目名称:Dropout_BBalpha,代码行数:18,代码来源:attacks_tf.py


注:本文中的tensorflow.python.platform.flags.FLAGS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。