Module: CNTK::Ops
- Defined in:
- lib/cntk/ops.rb
Class Method Summary collapse
- .abs(x = nil, y = nil, name: "") ⇒ Object
-
.alias(x, name = "") ⇒ Object
ops.
- .batch_normalization(x, scale: nil, bias: nil, mean: nil, variance: nil, spatial: false, normalization_time_constant: 5000, blend_time_constant: 0, epsilon: 0.00001, use_cudnn_engine: false, name: "", running_count: 0) ⇒ Object
- .binary_cross_entropy(x = nil, y = nil, name: "") ⇒ Object
- .ceil(x = nil, name: "") ⇒ Object
- .classification_error(output, target, axis = -1,, topN = 1, name = "") ⇒ Object
- .clip(x, min, max, name = "") ⇒ Object
- .combine(array, name = "") ⇒ Object
- .constant(*args) ⇒ Object
- .convert_to_one_variable(x, dtype = Numo::SFloat) ⇒ Object
- .convert_to_pooling_type(type) ⇒ Object
- .convert_to_variable(*vars) ⇒ Object
- .convolution(kernel: nil, input: nil, strides: [1], sharing: [true], padding: [false], lower_pad: [0], upper_pad: [0], max_temp_mem_size_in_samples: 0, name: "") ⇒ Object
- .cos(x = nil, name: "") ⇒ Object
- .cosine_distance(x = nil, y = nil, name: "") ⇒ Object
- .cross_entropy_with_softmax(output, target, axis = 0, name = "") ⇒ Object
- .dropout(x, rate = 0.0, name = "") ⇒ Object
-
.edit_distance_error(input_a, input_b, subPen = 0, delPen = 0, insPen = 0, squashInputs = false, samplesToIgnore = [], name = '') ⇒ Object
FIXME.
- .element_divide(x = nil, y = nil, name: "") ⇒ Object
- .element_select(x, if_true, if_else, name = "") ⇒ Object
- .element_times(x = nil, y = nil, name: "") ⇒ Object
- .equal(x = nil, y = nil, name: "") ⇒ Object
- .exp(x = nil, name: "") ⇒ Object
- .floor(x = nil, name: "") ⇒ Object
- .future_value(x, init = 0, time_step = 1, name = "") ⇒ Object
- .greater(x = nil, y = nil, name: "") ⇒ Object
- .greater_equal(x = nil, y = nil, name: "") ⇒ Object
- .hardmax(x = nil, name: "") ⇒ Object
- .highest_precision_type(*args) ⇒ Object
-
.input_variable(shape, dtype: DataType_Float, needs_gradient: false, is_sparse: false, dynamic_axes: nil, name: '') ⇒ Object
variable ops.
-
.lambda_rank(output, gain, group, name = "") ⇒ Object
FIXME.
- .less(x = nil, y = nil, name: "") ⇒ Object
- .less_equal(x = nil, y = nil, name: "") ⇒ Object
- .log(x = nil, name: "") ⇒ Object
- .log_add_exp(x = nil, y = nil, name: "") ⇒ Object
- .minus(x = nil, y = nil, name: "") ⇒ Object
-
.ndcg_at_1(output, gain, group, name = "") ⇒ Object
FIXME.
- .negate(x = nil, name: "") ⇒ Object
- .not_equal(x = nil, y = nil, name: "") ⇒ Object
- .output_variable(shape: nil, dtype: nil, dynamic_axes: nil, name: "") ⇒ Object
- .parameter(*args) ⇒ Object
- .past_value(x, init = 0, time_step = 1, name = "") ⇒ Object
- .placeholder_variable(shape: NDShape.unknown.dimensions(), name: "", dynamic_axes: nil) ⇒ Object
- .plus(x = nil, y = nil, name: "") ⇒ Object
- .pooling(x, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], ceil_out_dim: false, name: "") ⇒ Object
- .random_sample(weights, num_samples, allow_dup, name = "") ⇒ Object
- .random_sample_inclusion_frequency(weights, num_samples, allow_dup, name = "") ⇒ Object
- .reciprocal(x = nil, name: "") ⇒ Object
- .reduce_log_sum_exp(x, axis = nil, name = "") ⇒ Object
- .reduce_max(x, axis = nil, name = "") ⇒ Object
- .reduce_mean(x, axis = nil, name = "") ⇒ Object
- .reduce_min(x, axis = nil, name = "") ⇒ Object
- .reduce_prod(x, axis = nil, name = "") ⇒ Object
- .reduce_sum(x, axis = nil, name = "") ⇒ Object
- .relu(x = nil, name: "") ⇒ Object
- .reshape(x, shape, begin_axis = Axis.new(0), end_axis = Axis.end_static_axis(), name = "") ⇒ Object
- .reverse_dynamic_axes(axes) ⇒ Object
- .reverse_reshape_axis(axis) ⇒ Object
-
.roipooling(x, rois, shape, name = "") ⇒ Object
CNTK’s NDArray is column-major.
- .round(x = nil, name: "") ⇒ Object
- .sigmoid(x = nil, name: "") ⇒ Object
- .sin(x = nil, name: "") ⇒ Object
- .slice(x, axis, begin_index, end_index, name = "") ⇒ Object
- .softmax(x = nil, name: "") ⇒ Object
- .splice(x, axis = -1,, name = "") ⇒ Object
- .sqrt(x = nil, name: "") ⇒ Object
- .square(x = nil, name: "") ⇒ Object
- .squared_error(x = nil, y = nil, name: "") ⇒ Object
- .tanh(x = nil, name: "") ⇒ Object
- .times(left, right, output_rank: 1, infer_input_rank_to_map: -1,, name: "") ⇒ Object
- .times_transpose(left, right, output_rank = 1, name = "") ⇒ Object
- .transpose(x, axis1 = 0, axis2 = 1, name = "") ⇒ Object
- .unpooling(operand, input, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], name: "") ⇒ Object
- .weighted_binary_cross_entropy(output, target, weight, name = "") ⇒ Object
Class Method Details
.abs(x = nil, y = nil, name: "") ⇒ Object
466 467 468 469 470 471 |
# File 'lib/cntk/ops.rb', line 466 def abs(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.abs(x, y, name) end |
.alias(x, name = "") ⇒ Object
ops
132 133 134 135 |
# File 'lib/cntk/ops.rb', line 132 def alias(x, name="") x = Ops.convert_to_variable( x ) CNTK.__alias__(x, name) end |
.batch_normalization(x, scale: nil, bias: nil, mean: nil, variance: nil, spatial: false, normalization_time_constant: 5000, blend_time_constant: 0, epsilon: 0.00001, use_cudnn_engine: false, name: "", running_count: 0) ⇒ Object
199 200 201 202 203 204 205 206 207 |
# File 'lib/cntk/ops.rb', line 199 def batch_normalization(x, scale: nil, bias: nil, mean: nil, variance: nil, spatial: false, normalization_time_constant: 5000, blend_time_constant: 0, epsilon: 0.00001, use_cudnn_engine: false, name: "", running_count: 0) x, scale, bias, mean, variance, running_count = Ops.convert_to_variable( x, scale, bias, mean, variance, running_count ) CNTK.__batch_normalization__(x, scale, bias, mean, variance, running_count, spatial, normalization_time_constant, blend_time_constant, epsilon, use_cudnn_engine, name) end |
.binary_cross_entropy(x = nil, y = nil, name: "") ⇒ Object
536 537 538 539 540 541 |
# File 'lib/cntk/ops.rb', line 536 def binary_cross_entropy(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__binary_cross_entropy__(x, y, name) end |
.ceil(x = nil, name: "") ⇒ Object
421 422 423 424 425 |
# File 'lib/cntk/ops.rb', line 421 def ceil(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__ceil__(x, name) end |
.classification_error(output, target, axis = -1,, topN = 1, name = "") ⇒ Object
335 336 337 338 339 |
# File 'lib/cntk/ops.rb', line 335 def classification_error(output, target, axis=-1, topN=1, name="") output, target = Ops.convert_to_variable( output, target ) axis = Axis::from_num(axis) CNTK.__classification_error__(output, target, topN, axis, name) end |
.clip(x, min, max, name = "") ⇒ Object
220 221 222 223 |
# File 'lib/cntk/ops.rb', line 220 def clip(x, min, max, name="") x, min, max = Ops.convert_to_variable( x, min, max ) CNTK.__clip__(x, min, max, name) end |
.combine(array, name = "") ⇒ Object
151 152 153 154 |
# File 'lib/cntk/ops.rb', line 151 def combine(array, name="") a = array.map{|x| Ops.convert_to_variable( x ) } CNTK.__combine__(a, name) end |
.constant(*args) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/cntk/ops.rb', line 117 def constant(*args) val = args[0] if val.is_a?(Array) args[0] = Numo::SFloat[*val] end Constant.create(*args) end |
.convert_to_one_variable(x, dtype = Numo::SFloat) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cntk/ops.rb', line 50 def convert_to_one_variable(x, dtype = Numo::SFloat) case x when Variable x when Function x.output when Value, Numo::NArray, Numeric Ops.constant(x) when Array Ops.constant( dtype[*x] ) else raise ArgumentError, "CNTK::Variable, Numo::NArray, or Array expected" end end |
.convert_to_pooling_type(type) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cntk/ops.rb', line 30 def convert_to_pooling_type(type) case type when :max type = CNTK::PoolingType_Max when :average type = CNTK::PoolingType_Average else raise ArgumentError, "unknown pooling type" end end |
.convert_to_variable(*vars) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/cntk/ops.rb', line 41 def convert_to_variable(*vars) if vars.size == 1 convert_to_one_variable(vars[0]) else dtype = highest_precision_type(*vars) return vars.map{|v| convert_to_one_variable(v, dtype) } end end |
.convolution(kernel: nil, input: nil, strides: [1], sharing: [true], padding: [false], lower_pad: [0], upper_pad: [0], max_temp_mem_size_in_samples: 0, name: "") ⇒ Object
156 157 158 159 160 161 162 163 |
# File 'lib/cntk/ops.rb', line 156 def convolution(kernel: nil, input: nil, strides: [1], sharing: [true], padding: [false], lower_pad: [0], upper_pad: [0], max_temp_mem_size_in_samples: 0, name: "") kernel = Ops.convert_to_variable( kernel ) input = Ops.convert_to_variable( input ) CNTK.__convolution__(kernel, input, strides, sharing, padding, lower_pad, upper_pad, max_temp_mem_size_in_samples, name) end |
.cos(x = nil, name: "") ⇒ Object
373 374 375 376 377 |
# File 'lib/cntk/ops.rb', line 373 def cos(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__cos__(x, name) end |
.cosine_distance(x = nil, y = nil, name: "") ⇒ Object
529 530 531 532 533 534 |
# File 'lib/cntk/ops.rb', line 529 def cosine_distance(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__cosine_distance__(x, y, name) end |
.cross_entropy_with_softmax(output, target, axis = 0, name = "") ⇒ Object
144 145 146 147 148 149 |
# File 'lib/cntk/ops.rb', line 144 def cross_entropy_with_softmax(output, target, axis=0, name="") output = Ops.convert_to_variable( output ) target = Ops.convert_to_variable( target ) axis = Axis.from_num(axis) CNTK.__cross_entropy_with_softmax__(output, target, axis, name) end |
.dropout(x, rate = 0.0, name = "") ⇒ Object
315 316 317 318 319 320 321 |
# File 'lib/cntk/ops.rb', line 315 def dropout(x, rate=0.0, name="") if rate < 0 or rate >= 1 raise ArgumentError, "dropout_rate must be in the interval [0,1)" end x = Ops.convert_to_variable( x ) CNTK.__dropout__(x, rate, name) end |
.edit_distance_error(input_a, input_b, subPen = 0, delPen = 0, insPen = 0, squashInputs = false, samplesToIgnore = [], name = '') ⇒ Object
FIXME
342 343 344 345 346 347 |
# File 'lib/cntk/ops.rb', line 342 def edit_distance_error(input_a, input_b, subPen=0, delPen=0, insPen=0, squashInputs=false, samplesToIgnore=[], name='') input_a = Ops.convert_to_variable( input_a ) input_b = Ops.convert_to_variable( input_b ) CNTK.__edit_distance_error__(input_a, input_b, subPen, delPen, insPen, squashInputs, samplesToIgnore, name) end |
.element_divide(x = nil, y = nil, name: "") ⇒ Object
480 481 482 483 484 485 |
# File 'lib/cntk/ops.rb', line 480 def element_divide(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__element_divide__(x, y, name) end |
.element_select(x, if_true, if_else, name = "") ⇒ Object
225 226 227 228 |
# File 'lib/cntk/ops.rb', line 225 def element_select(x, if_true, if_else, name="") x, if_true, if_else = Ops.convert_to_variable( x, if_true, if_else ) CNTK.__element_select__(x, if_true, if_else, name) end |
.element_times(x = nil, y = nil, name: "") ⇒ Object
473 474 475 476 477 478 |
# File 'lib/cntk/ops.rb', line 473 def element_times(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__element_times__(x, y, name) end |
.equal(x = nil, y = nil, name: "") ⇒ Object
487 488 489 490 491 492 |
# File 'lib/cntk/ops.rb', line 487 def equal(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__equal__(x, y, name) end |
.exp(x = nil, name: "") ⇒ Object
385 386 387 388 389 |
# File 'lib/cntk/ops.rb', line 385 def exp(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__exp__(x, name) end |
.floor(x = nil, name: "") ⇒ Object
415 416 417 418 419 |
# File 'lib/cntk/ops.rb', line 415 def floor(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__floor__(x, name) end |
.future_value(x, init = 0, time_step = 1, name = "") ⇒ Object
230 231 232 233 |
# File 'lib/cntk/ops.rb', line 230 def future_value(x, init=0, time_step=1, name="") x, init = Ops.convert_to_variable( x, init ) CNTK.__future_value__(x, init, time_step, name) end |
.greater(x = nil, y = nil, name: "") ⇒ Object
515 516 517 518 519 520 |
# File 'lib/cntk/ops.rb', line 515 def greater(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__greater__(x, y, name) end |
.greater_equal(x = nil, y = nil, name: "") ⇒ Object
522 523 524 525 526 527 |
# File 'lib/cntk/ops.rb', line 522 def greater_equal(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__greater_equal__(x, y, name) end |
.hardmax(x = nil, name: "") ⇒ Object
439 440 441 442 443 |
# File 'lib/cntk/ops.rb', line 439 def hardmax(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__hardmax__(x, name) end |
.highest_precision_type(*args) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cntk/ops.rb', line 65 def highest_precision_type(*args) types = args.map{|v| case v when Variable Variable::DataType[v.get_data_type] when Numo::NArray v.class else nil end } if types.include?(Numo::DFloat) Numo::DFloat else Numo::SFloat end end |
.input_variable(shape, dtype: DataType_Float, needs_gradient: false, is_sparse: false, dynamic_axes: nil, name: '') ⇒ Object
variable ops
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/cntk/ops.rb', line 89 def input_variable(shape, dtype: DataType_Float, needs_gradient: false, is_sparse: false, dynamic_axes: nil, name: '') if dynamic_axes dynamic_axes = dynamic_axes.reverse else dynamic_axes = Axis.default_input_variable_dynamic_axes() end CNTK.__input_variable__(shape, is_sparse, dtype, needs_gradient, name, dynamic_axes) end |
.lambda_rank(output, gain, group, name = "") ⇒ Object
FIXME
324 325 326 327 |
# File 'lib/cntk/ops.rb', line 324 def lambda_rank(output, gain, group, name="") output, gain, group = Ops.convert_to_variable( output, gain, group ) CNTK.__lambda_rank__(output, gain, group, name) end |
.less(x = nil, y = nil, name: "") ⇒ Object
501 502 503 504 505 506 |
# File 'lib/cntk/ops.rb', line 501 def less(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__less__(x, y, name) end |
.less_equal(x = nil, y = nil, name: "") ⇒ Object
508 509 510 511 512 513 |
# File 'lib/cntk/ops.rb', line 508 def less_equal(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__less_equal__(x, y, name) end |
.log(x = nil, name: "") ⇒ Object
391 392 393 394 395 |
# File 'lib/cntk/ops.rb', line 391 def log(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__log__(x, name) end |
.log_add_exp(x = nil, y = nil, name: "") ⇒ Object
459 460 461 462 463 464 |
# File 'lib/cntk/ops.rb', line 459 def log_add_exp(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__log_add_exp__(x, y, name) end |
.minus(x = nil, y = nil, name: "") ⇒ Object
452 453 454 455 456 457 |
# File 'lib/cntk/ops.rb', line 452 def minus(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__minus__(x, y, name) end |
.ndcg_at_1(output, gain, group, name = "") ⇒ Object
FIXME
330 331 332 333 |
# File 'lib/cntk/ops.rb', line 330 def ndcg_at_1(output, gain, group, name="") output, gain, group = Ops.convert_to_variable( output, gain, group ) CNTK.__ndcgat1__(output, gain, group, name) end |
.negate(x = nil, name: "") ⇒ Object
349 350 351 352 353 |
# File 'lib/cntk/ops.rb', line 349 def negate(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__negate__(x, name) end |
.not_equal(x = nil, y = nil, name: "") ⇒ Object
494 495 496 497 498 499 |
# File 'lib/cntk/ops.rb', line 494 def not_equal(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__not_equal__(x, y, name) end |
.output_variable(shape: nil, dtype: nil, dynamic_axes: nil, name: "") ⇒ Object
101 102 103 104 105 106 |
# File 'lib/cntk/ops.rb', line 101 def output_variable(shape: nil, dtype: nil, dynamic_axes: nil, name: "") if dynamic_axes dynamic_axes = dynamic_axes.reverse end CNTK.__output_variable__(shape, dtype, dynamic_axes, name) end |
.parameter(*args) ⇒ Object
125 126 127 |
# File 'lib/cntk/ops.rb', line 125 def parameter(*args) Parameter.create(*args) end |
.past_value(x, init = 0, time_step = 1, name = "") ⇒ Object
235 236 237 238 |
# File 'lib/cntk/ops.rb', line 235 def past_value(x, init=0, time_step=1, name="") x, init = Ops.convert_to_variable( x, init ) CNTK.__past_value__(x, init, time_step, name) end |
.placeholder_variable(shape: NDShape.unknown.dimensions(), name: "", dynamic_axes: nil) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/cntk/ops.rb', line 108 def placeholder_variable(shape: NDShape.unknown.dimensions(), name: "", dynamic_axes: nil) if dynamic_axes dynamic_axes = dynamic_axes.reverse else dynamic_axes = Axis.unknown_dynamic_axes end CNTK.__placeholder_variable__(shape, name, dynamic_axes) end |
.plus(x = nil, y = nil, name: "") ⇒ Object
445 446 447 448 449 450 |
# File 'lib/cntk/ops.rb', line 445 def plus(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__plus__(x, y, name) end |
.pooling(x, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], ceil_out_dim: false, name: "") ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/cntk/ops.rb', line 178 def pooling(x, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], ceil_out_dim: false, name: "") x = Ops.convert_to_variable( x ) case type when :max type = CNTK::PoolingType_Max when :average type = CNTK::PoolingType_Average else raise ArgumentError, "unknown pooling type" end CNTK.__pooling__(x, type, shape, strides, padding, lower_pad, upper_pad, ceil_out_dim, name) end |
.random_sample(weights, num_samples, allow_dup, name = "") ⇒ Object
305 306 307 308 |
# File 'lib/cntk/ops.rb', line 305 def random_sample(weights, num_samples, allow_dup, name="") weights = Ops.convert_to_variable( weights ) CNTK.__random_sample__(weights, num_samples, allow_dup, name) end |
.random_sample_inclusion_frequency(weights, num_samples, allow_dup, name = "") ⇒ Object
310 311 312 313 |
# File 'lib/cntk/ops.rb', line 310 def random_sample_inclusion_frequency(weights, num_samples, allow_dup, name="") weights = Ops.convert_to_variable( weights ) CNTK.__random_sample_inclusion_frequency__(weights, num_samples, allow_dup, name) end |
.reciprocal(x = nil, name: "") ⇒ Object
427 428 429 430 431 |
# File 'lib/cntk/ops.rb', line 427 def reciprocal(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__reciprocal__(x, name) end |
.reduce_log_sum_exp(x, axis = nil, name = "") ⇒ Object
275 276 277 278 279 |
# File 'lib/cntk/ops.rb', line 275 def reduce_log_sum_exp(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_log_sum__(x, axis, name) end |
.reduce_max(x, axis = nil, name = "") ⇒ Object
287 288 289 290 291 |
# File 'lib/cntk/ops.rb', line 287 def reduce_max(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_max__(x, axis, name) end |
.reduce_mean(x, axis = nil, name = "") ⇒ Object
281 282 283 284 285 |
# File 'lib/cntk/ops.rb', line 281 def reduce_mean(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_mean__(x, axis, name) end |
.reduce_min(x, axis = nil, name = "") ⇒ Object
293 294 295 296 297 |
# File 'lib/cntk/ops.rb', line 293 def reduce_min(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_min__(x, axis, name) end |
.reduce_prod(x, axis = nil, name = "") ⇒ Object
299 300 301 302 303 |
# File 'lib/cntk/ops.rb', line 299 def reduce_prod(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_prod__(x, axis, name) end |
.reduce_sum(x, axis = nil, name = "") ⇒ Object
269 270 271 272 273 |
# File 'lib/cntk/ops.rb', line 269 def reduce_sum(x, axis=nil, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__reduce_sum__(x, axis, name) end |
.relu(x = nil, name: "") ⇒ Object
379 380 381 382 383 |
# File 'lib/cntk/ops.rb', line 379 def relu(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__re_lu__(x, name) end |
.reshape(x, shape, begin_axis = Axis.new(0), end_axis = Axis.end_static_axis(), name = "") ⇒ Object
240 241 242 243 244 245 |
# File 'lib/cntk/ops.rb', line 240 def reshape(x, shape, begin_axis=Axis.new(0), end_axis=Axis.end_static_axis(), name="") x = Ops.convert_to_variable( x ) begin_axis = Ops.reverse_reshape_axis(begin_axis) end_axis = Ops.reverse_reshape_axis(end_axis ) CNTK.__reshape__(x, shape, begin_axis, end_axis, name) end |
.reverse_dynamic_axes(axes) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/cntk/ops.rb', line 22 def reverse_dynamic_axes(axes) axes = [axes] unless axes.is_a?(Array) axes.each{|ax| raise ArgumentError, "Axis expected" unless ax.is_a?(Axis) } axes.reverse end |
.reverse_reshape_axis(axis) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cntk/ops.rb', line 8 def reverse_reshape_axis(axis) axis = Axis.new(axis) if axis.is_a?(Numeric) case when axis.is_static_axis axis when axis == Axis.end_static_axis Axis.new(0) when axis == Axis.new(0) Axis.end_static_axis else Axis(-axis.static_axis_index) end end |
.roipooling(x, rois, shape, name = "") ⇒ Object
CNTK’s NDArray is column-major. So to specify rois, remember it.
y
__________
|
x|
|
173 174 175 176 |
# File 'lib/cntk/ops.rb', line 173 def roipooling(x, rois, shape, name="") x, rois = Ops.convert_to_variable( x, rois ) CNTK.__roipooling__(x, rois, shape, name) end |
.round(x = nil, name: "") ⇒ Object
409 410 411 412 413 |
# File 'lib/cntk/ops.rb', line 409 def round(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__round__(x, name) end |
.sigmoid(x = nil, name: "") ⇒ Object
355 356 357 358 359 |
# File 'lib/cntk/ops.rb', line 355 def sigmoid(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__sigmoid__(x, name) end |
.sin(x = nil, name: "") ⇒ Object
367 368 369 370 371 |
# File 'lib/cntk/ops.rb', line 367 def sin(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__sin__(x, name) end |
.slice(x, axis, begin_index, end_index, name = "") ⇒ Object
257 258 259 260 261 |
# File 'lib/cntk/ops.rb', line 257 def slice(x, axis, begin_index, end_index, name="") x = Ops.convert_to_variable( x ) axis = Axis.from_num(axis) CNTK.__slice__(x, axis, begin_index, end_index, name) end |
.softmax(x = nil, name: "") ⇒ Object
433 434 435 436 437 |
# File 'lib/cntk/ops.rb', line 433 def softmax(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__softmax__(x, name) end |
.splice(x, axis = -1,, name = "") ⇒ Object
263 264 265 266 267 |
# File 'lib/cntk/ops.rb', line 263 def splice(x, axis=-1, name="") x = x.map{|var| Ops.convert_to_variable( var ) } axis = Axis.from_num(axis) CNTK.__splice__(x, axis, name) end |
.sqrt(x = nil, name: "") ⇒ Object
403 404 405 406 407 |
# File 'lib/cntk/ops.rb', line 403 def sqrt(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__sqrt__(x, name) end |
.square(x = nil, name: "") ⇒ Object
397 398 399 400 401 |
# File 'lib/cntk/ops.rb', line 397 def square(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__square__(x, name) end |
.squared_error(x = nil, y = nil, name: "") ⇒ Object
543 544 545 546 547 548 |
# File 'lib/cntk/ops.rb', line 543 def squared_error(x=nil, y=nil, name: "") x = x || Ops.placeholder_variable(name: "x") y = y || Ops.placeholder_variable(name: "y") x, y = Ops.convert_to_variable( x, y ) CNTK.__squared_error__(x, y, name) end |
.tanh(x = nil, name: "") ⇒ Object
361 362 363 364 365 |
# File 'lib/cntk/ops.rb', line 361 def tanh(x=nil, name: "") x = x || Ops.placeholder_variable(name: "x") x = Ops.convert_to_variable( x ) CNTK.__tanh__(x, name) end |
.times(left, right, output_rank: 1, infer_input_rank_to_map: -1,, name: "") ⇒ Object
209 210 211 212 213 |
# File 'lib/cntk/ops.rb', line 209 def times(left, right, output_rank: 1, infer_input_rank_to_map: -1, name: "") left, right = Ops.convert_to_variable( left, right ) # change the order because CNTK a column-major. CNTK.__times__(right, left, output_rank, infer_input_rank_to_map, name) end |
.times_transpose(left, right, output_rank = 1, name = "") ⇒ Object
215 216 217 218 |
# File 'lib/cntk/ops.rb', line 215 def times_transpose(left, right, output_rank = 1, name="") left, right = Ops.convert_to_variable( left, right ) CNTK.__transpose_times__(right, left, output_rank, name="") end |
.transpose(x, axis1 = 0, axis2 = 1, name = "") ⇒ Object
247 248 249 250 251 252 253 254 255 |
# File 'lib/cntk/ops.rb', line 247 def transpose(x, axis1=0, axis2=1, name="") x = Ops.convert_to_variable( x ) unless axis1.abs <= x.shape.rank and axis2.abs <= x.shape.rank raise ArgumentError, "out of bounds" end axis1 = Axis.from_num(axis1) axis2 = Axis.from_num(axis2) CNTK.__transpose_axes__(x, axis1, axis2, name) end |
.unpooling(operand, input, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], name: "") ⇒ Object
192 193 194 195 196 197 |
# File 'lib/cntk/ops.rb', line 192 def unpooling(operand, input, type, shape, strides: [1], padding: [false], lower_pad: [0], upper_pad: [0], name: "") operand, input = Ops.convert_to_variable( operand, input ) type = Ops.convert_to_pooling_type( type ) CNTK.__unpooling__(operand, input, type, shape, strides, padding, lower_pad, upper_pad, name) end |
.weighted_binary_cross_entropy(output, target, weight, name = "") ⇒ Object
137 138 139 140 141 142 |
# File 'lib/cntk/ops.rb', line 137 def weighted_binary_cross_entropy(output, target, weight, name="") output = Ops.convert_to_variable( output ) target = Ops.convert_to_variable( target ) weight = Ops.convert_to_variable( weight ) CNTK.__weighted_binary_cross_entropy__(output, target, weight, name) end |