Python features.py() Examples
The following are 9
code examples of features.py().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
features
, or try the search function
.
Example #1
Source File: dualnet.py From Gun-Detector with Apache License 2.0 | 6 votes |
def get_inference_input(params): """Set up placeholders for input features/labels. Args: params: An object to indicate the hyperparameters of the model. Returns: The features and output tensors that get passed into model_fn. Check dualnet_model.py for more details on the models input and output. """ input_features = tf.placeholder( tf.float32, [None, params.board_size, params.board_size, features.NEW_FEATURES_PLANES], name='pos_tensor') labels = { 'pi_tensor': tf.placeholder( tf.float32, [None, params.board_size * params.board_size + 1]), 'value_tensor': tf.placeholder(tf.float32, [None]) } return input_features, labels
Example #2
Source File: dualnet.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def get_inference_input(params): """Set up placeholders for input features/labels. Args: params: An object to indicate the hyperparameters of the model. Returns: The features and output tensors that get passed into model_fn. Check dualnet_model.py for more details on the models input and output. """ input_features = tf.placeholder( tf.float32, [None, params.board_size, params.board_size, features.NEW_FEATURES_PLANES], name='pos_tensor') labels = { 'pi_tensor': tf.placeholder( tf.float32, [None, params.board_size * params.board_size + 1]), 'value_tensor': tf.placeholder(tf.float32, [None]) } return input_features, labels
Example #3
Source File: dualnet.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def get_inference_input(params): """Set up placeholders for input features/labels. Args: params: An object to indicate the hyperparameters of the model. Returns: The features and output tensors that get passed into model_fn. Check dualnet_model.py for more details on the models input and output. """ input_features = tf.placeholder( tf.float32, [None, params.board_size, params.board_size, features.NEW_FEATURES_PLANES], name='pos_tensor') labels = { 'pi_tensor': tf.placeholder( tf.float32, [None, params.board_size * params.board_size + 1]), 'value_tensor': tf.placeholder(tf.float32, [None]) } return input_features, labels
Example #4
Source File: dualnet.py From Gun-Detector with Apache License 2.0 | 5 votes |
def run(self, position, use_random_symmetry=True): """Compute the policy and value output for a given position. Args: position: A given go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted feature (defined in features.py) of the given position Returns: prob, value: The policy and value output (defined in dualnet_model.py) """ probs, values = self.run_many( [position], use_random_symmetry=use_random_symmetry) return probs[0], values[0]
Example #5
Source File: dualnet.py From Gun-Detector with Apache License 2.0 | 5 votes |
def run_many(self, positions, use_random_symmetry=True): """Compute the policy and value output for given positions. Args: positions: A list of positions for go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted features (defined in features.py) of the given positions Returns: probabilities, value: The policy and value outputs (defined in dualnet_model.py) """ def _extract_features(positions): return features.extract_features(self.hparams.board_size, positions) processed = list(map(_extract_features, positions)) # processed = [ # features.extract_features(self.hparams.board_size, p) for p in positions] if use_random_symmetry: syms_used, processed = symmetries.randomize_symmetries_feat(processed) # feed_dict is a dict object to provide the input examples for the step of # inference. sess.run() returns the inference predictions (indicated by # self.inference_output) of the given input as outputs outputs = self.sess.run( self.inference_output, feed_dict={self.inference_input: processed}) probabilities, value = outputs['policy_output'], outputs['value_output'] if use_random_symmetry: probabilities = symmetries.invert_symmetries_pi( self.hparams.board_size, syms_used, probabilities) return probabilities, value
Example #6
Source File: dualnet.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def run(self, position, use_random_symmetry=True): """Compute the policy and value output for a given position. Args: position: A given go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted feature (defined in features.py) of the given position Returns: prob, value: The policy and value output (defined in dualnet_model.py) """ probs, values = self.run_many( [position], use_random_symmetry=use_random_symmetry) return probs[0], values[0]
Example #7
Source File: dualnet.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def run_many(self, positions, use_random_symmetry=True): """Compute the policy and value output for given positions. Args: positions: A list of positions for go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted features (defined in features.py) of the given positions Returns: probabilities, value: The policy and value outputs (defined in dualnet_model.py) """ def _extract_features(positions): return features.extract_features(self.hparams.board_size, positions) processed = list(map(_extract_features, positions)) # processed = [ # features.extract_features(self.hparams.board_size, p) for p in positions] if use_random_symmetry: syms_used, processed = symmetries.randomize_symmetries_feat(processed) # feed_dict is a dict object to provide the input examples for the step of # inference. sess.run() returns the inference predictions (indicated by # self.inference_output) of the given input as outputs outputs = self.sess.run( self.inference_output, feed_dict={self.inference_input: processed}) probabilities, value = outputs['policy_output'], outputs['value_output'] if use_random_symmetry: probabilities = symmetries.invert_symmetries_pi( self.hparams.board_size, syms_used, probabilities) return probabilities, value
Example #8
Source File: dualnet.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def run(self, position, use_random_symmetry=True): """Compute the policy and value output for a given position. Args: position: A given go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted feature (defined in features.py) of the given position Returns: prob, value: The policy and value output (defined in dualnet_model.py) """ probs, values = self.run_many( [position], use_random_symmetry=use_random_symmetry) return probs[0], values[0]
Example #9
Source File: dualnet.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def run_many(self, positions, use_random_symmetry=True): """Compute the policy and value output for given positions. Args: positions: A list of positions for go board status use_random_symmetry: Apply random symmetry (defined in symmetries.py) to the extracted features (defined in features.py) of the given positions Returns: probabilities, value: The policy and value outputs (defined in dualnet_model.py) """ def _extract_features(positions): return features.extract_features(self.hparams.board_size, positions) processed = list(map(_extract_features, positions)) # processed = [ # features.extract_features(self.hparams.board_size, p) for p in positions] if use_random_symmetry: syms_used, processed = symmetries.randomize_symmetries_feat(processed) # feed_dict is a dict object to provide the input examples for the step of # inference. sess.run() returns the inference predictions (indicated by # self.inference_output) of the given input as outputs outputs = self.sess.run( self.inference_output, feed_dict={self.inference_input: processed}) probabilities, value = outputs['policy_output'], outputs['value_output'] if use_random_symmetry: probabilities = symmetries.invert_symmetries_pi( self.hparams.board_size, syms_used, probabilities) return probabilities, value