Python cntk.one_hot() Examples
The following are 30
code examples of cntk.one_hot().
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
cntk
, or try the search function
.
Example #1
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #2
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #3
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #4
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #5
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def sparse_categorical_crossentropy(target, output, from_logits=False): target = C.one_hot(target, output.shape[-1]) target = C.reshape(target, output.shape) return categorical_crossentropy(target, output, from_logits)
Example #6
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #7
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #8
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def sparse_categorical_crossentropy(target, output, from_logits=False): target = C.one_hot(target, output.shape[-1]) target = C.reshape(target, output.shape) return categorical_crossentropy(target, output, from_logits)
Example #9
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #10
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #11
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #12
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #13
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #14
Source File: cntk_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will udpate with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_class = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_class) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #15
Source File: cntk_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def sparse_categorical_crossentropy(target, output, from_logits=False): target = C.one_hot(target, output.shape[-1]) target = C.reshape(target, output.shape) return categorical_crossentropy(target, output, from_logits)
Example #16
Source File: cntk_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def one_hot(indices, nb_classes): return C.one_hot(indices, nb_classes)
Example #17
Source File: cntk_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #18
Source File: cntk_backend.py From keras-lambda with MIT License | 5 votes |
def sparse_categorical_crossentropy(output, target, from_logits=False): target = C.one_hot(target, output.shape[-1]) target = C.reshape(target, output.shape) return categorical_crossentropy(output, target, from_logits)
Example #19
Source File: cntk_backend.py From keras-lambda with MIT License | 5 votes |
def one_hot(indices, nb_classes): return C.one_hot(indices, nb_classes)
Example #20
Source File: cntk_backend.py From keras-lambda with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #21
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #22
Source File: cntk_backend.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def sparse_categorical_crossentropy(target, output, from_logits=False, axis=-1): # Here, unlike other backends, the tensors lack a batch dimension: axis_without_batch = -1 if axis == -1 else axis - 1 output_dimensions = list(range(len(output.shape))) if axis_without_batch != -1 and axis_without_batch not in output_dimensions: raise ValueError( '{}{}{}'.format( 'Unexpected channels axis {}. '.format(axis_without_batch), 'Expected to be -1 or one of the axes of `output`, ', 'which has {} dimensions.'.format(len(output.shape)))) target = C.one_hot(target, output.shape[axis_without_batch], axis=axis_without_batch) target = C.reshape(target, output.shape) return categorical_crossentropy(target, output, from_logits, axis=axis)
Example #23
Source File: cntk_backend.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #24
Source File: cntk_backend.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #25
Source File: cntk_emitter.py From MMdnn with MIT License | 5 votes |
def emit_Embedding(self, IR_node): codes = list() codes.append("{}_P = cntk.one_hot({}, __weights_dict['{}']['weights'].shape[0])".format( IR_node.variable_name, self.parent_variable_name(IR_node), IR_node.name)) codes.append("{:<15} = layers.Embedding(weights=__weights_dict['{}']['weights'])({}_P)".format( IR_node.variable_name, # IR_node.get_attr('output_dim'), IR_node.name, IR_node.variable_name)) return codes
Example #26
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)
Example #27
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def sparse_categorical_crossentropy(target, output, from_logits=False): target = C.one_hot(target, output.shape[-1]) target = C.reshape(target, output.shape) return categorical_crossentropy(target, output, from_logits)
Example #28
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def one_hot(indices, num_classes): return C.one_hot(indices, num_classes)
Example #29
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def in_top_k(predictions, targets, k): _targets = C.one_hot(targets, predictions.shape[-1]) result = C.classification_error(predictions, _targets, topN=k) return 1 - C.reshape(result, shape=())
Example #30
Source File: cntk_backend.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
def gather(reference, indices): # There is a bug in cntk gather op which may cause crash. # We have made a fix but not catched in CNTK 2.1 release. # Will update with gather op in next release if _get_cntk_version() >= 2.2: return C.ops.gather(reference, indices) else: num_classes = reference.shape[0] one_hot_matrix = C.ops.one_hot(indices, num_classes) return C.times(one_hot_matrix, reference, output_rank=len(reference.shape) - 1)