public static void Run() { var input = new Input(new Keras.Shape(32, 32)); //var a = new CuDNNLSTM(32).Set(input); var a = new Dense(32, activation: "sigmoid").Set(input); //a.Set(input); var output = new Dense(1, activation: "sigmoid").Set(a); //output.Set(a); var model = new Keras.Models.Model(new Input[] { input }, new BaseLayer[] { output }); //Load train data Numpy.NDarray x = np.array(new float[, ] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } }); NDarray y = np.array(new float[] { 0, 1, 1, 0 }); var input1 = new Input(new Shape(32, 32, 3)); var conv1 = new Conv2D(32, (4, 4).ToTuple(), activation: "relu").Set(input1); var pool1 = new MaxPooling2D((2, 2).ToTuple()).Set(conv1); var flatten1 = new Flatten().Set(pool1); var input2 = new Input(new Shape(32, 32, 3)); var conv2 = new Conv2D(16, (8, 8).ToTuple(), activation: "relu").Set(input2); var pool2 = new MaxPooling2D((2, 2).ToTuple()).Set(conv2); var flatten2 = new Flatten().Set(pool2); var merge = new Concatenate(flatten1, flatten2); }
/// <summary> /// Evaluates the Einstein summation convention on the operands.<br></br> /// /// Using the Einstein summation convention, many common multi-dimensional, /// linear algebraic array operations can be represented in a simple fashion.<br></br> /// /// In implicit mode einsum computes these values.<br></br> /// /// In explicit mode, einsum provides further flexibility to compute /// other array operations that might not be considered classical Einstein /// summation operations, by disabling, or forcing summation over specified /// subscript labels.<br></br> /// /// See the notes and examples for clarification.<br></br> /// /// Notes /// /// The Einstein summation convention can be used to compute /// many multi-dimensional, linear algebraic array operations.<br></br> /// einsum /// provides a succinct way of representing these.<br></br> /// /// A non-exhaustive list of these operations, /// which can be computed by einsum, is shown below along with examples: /// /// The subscripts string is a comma-separated list of subscript labels, /// where each label refers to a dimension of the corresponding operand.<br></br> /// /// Whenever a label is repeated it is summed, so np.einsum('i,i', a, b) /// is equivalent to np.inner(a,b).<br></br> /// If a label /// appears only once, it is not summed, so np.einsum('i', a) produces a /// view of a with no changes.<br></br> /// A further example np.einsum('ij,jk', a, b) /// describes traditional matrix multiplication and is equivalent to /// np.matmul(a,b).<br></br> /// Repeated subscript labels in one /// operand take the diagonal.<br></br> /// For example, np.einsum('ii', a) is equivalent /// to np.trace(a).<br></br> /// /// In implicit mode, the chosen subscripts are important /// since the axes of the output are reordered alphabetically.<br></br> /// This /// means that np.einsum('ij', a) doesn’t affect a 2D array, while /// np.einsum('ji', a) takes its transpose.<br></br> /// Additionally, /// np.einsum('ij,jk', a, b) returns a matrix multiplication, while, /// np.einsum('ij,jh', a, b) returns the transpose of the /// multiplication since subscript ‘h’ precedes subscript ‘i’. /// /// In explicit mode the output can be directly controlled by /// specifying output subscript labels.<br></br> /// This requires the /// identifier ‘->’ as well as the list of output subscript labels.<br></br> /// /// This feature increases the flexibility of the function since /// summing can be disabled or forced when required.<br></br> /// The call /// np.einsum('i->', a) is like np.sum(a, axis=-1), /// and np.einsum('ii->i', a) is like np.diag(a).<br></br> /// /// The difference is that einsum does not allow broadcasting by default.<br></br> /// /// Additionally np.einsum('ij,jh->ih', a, b) directly specifies the /// order of the output subscript labels and therefore returns matrix /// multiplication, unlike the example above in implicit mode.<br></br> /// /// To enable and control broadcasting, use an ellipsis.<br></br> /// Default /// NumPy-style broadcasting is done by adding an ellipsis /// to the left of each term, like np.einsum('...ii->...i', a).<br></br> /// /// To take the trace along the first and last axes, /// you can do np.einsum('i...i', a), or to do a matrix-matrix /// product with the left-most indices instead of rightmost, one can do /// np.einsum('ij...,jk...->ik...', a, b).<br></br> /// /// When there is only one operand, no axes are summed, and no output /// parameter is provided, a view into the operand is returned instead /// of a new array.<br></br> /// Thus, taking the diagonal as np.einsum('ii->i', a) /// produces a view (changed in version 1.10.0).<br></br> /// /// einsum also provides an alternative way to provide the subscripts /// and operands as einsum(op0, sublist0, op1, sublist1, ..., [sublistout]).<br></br> /// /// If the output shape is not provided in this format einsum will be /// calculated in implicit mode, otherwise it will be performed explicitly.<br></br> /// /// The examples below have corresponding einsum calls with the two /// parameter methods.<br></br> /// /// Views returned from einsum are now writeable whenever the input array /// is writeable.<br></br> /// For example, np.einsum('ijk...->kji...', a) will now /// have the same effect as np.swapaxes(a, 0, 2) /// and np.einsum('ii->i', a) will return a writeable view of the diagonal /// of a 2D array.<br></br> /// /// Added the optimize argument which will optimize the contraction order /// of an einsum expression.<br></br> /// For a contraction with three or more operands this /// can greatly increase the computational efficiency at the cost of a larger /// memory footprint during computation.<br></br> /// /// Typically a ‘greedy’ algorithm is applied which empirical tests have shown /// returns the optimal path in the majority of cases.<br></br> /// In some cases ‘optimal’ /// will return the superlative path through a more expensive, exhaustive search.<br></br> /// /// For iterative calculations it may be advisable to calculate the optimal path /// once and reuse that path by supplying it as an argument.<br></br> /// An example is given /// below.<br></br> /// /// See numpy.einsum_path for more details. /// </summary> /// <param name="subscripts"> /// Specifies the subscripts for summation as comma separated list of /// subscript labels.<br></br> /// An implicit (classical Einstein summation) /// calculation is performed unless the explicit indicator ‘->’ is /// included as well as subscript labels of the precise output form. /// </param> /// <param name="operands"> /// These are the arrays for the operation. /// </param> /// <param name="out"> /// If provided, the calculation is done into this array. /// </param> /// <param name="dtype"> /// If provided, forces the calculation to use the data type specified.<br></br> /// /// Note that you may have to also give a more liberal casting /// parameter to allow the conversions.<br></br> /// Default is None. /// </param> /// <param name="order"> /// Controls the memory layout of the output.<br></br> /// ‘C’ means it should /// be C contiguous.<br></br> /// ‘F’ means it should be Fortran contiguous, /// ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise.<br></br> /// /// ‘K’ means it should be as close to the layout as the inputs as /// is possible, including arbitrarily permuted axes.<br></br> /// /// Default is ‘K’. /// </param> /// <param name="casting"> /// Controls what kind of data casting may occur.<br></br> /// Setting this to /// ‘unsafe’ is not recommended, as it can adversely affect accumulations.<br></br> /// /// Default is ‘safe’. /// </param> /// <param name="optimize"> /// Controls if intermediate optimization should occur.<br></br> /// No optimization /// will occur if False and True will default to the ‘greedy’ algorithm.<br></br> /// /// Also accepts an explicit contraction list from the np.einsum_path /// function.<br></br> /// See np.einsum_path for more details.<br></br> /// Defaults to False. /// </param> /// <returns> /// The calculation based on the Einstein summation convention. /// </returns> public static NDarray einsum(string subscripts, NDarray[] operands, NDarray @out = null, Dtype dtype = null, string order = null, string casting = "safe", object optimize = null) => NumPy.Instance.einsum(subscripts, operands, @out: @out, dtype: dtype, order: order, casting: casting, optimize: optimize);
/***************************************************/ public static np.NDarray Slice(this np.NDarray array, np.NDarray notation) { return(array[notation]); }
/// <summary> /// Test whether all array elements along a given axis evaluate to True.<br></br> /// /// Notes /// /// Not a Number (NaN), positive infinity and negative infinity /// evaluate to True because these are not equal to zero. /// </summary> /// <param name="a"> /// Input array or object that can be converted to an array. /// </param> /// <returns> /// A new boolean or array is returned unless out is specified, /// in which case a reference to out is returned. /// </returns> public static bool all(NDarray a) => NumPy.Instance.all(a);
/// <summary> /// Return (x1 != x2) element-wise. /// </summary> /// <param name="x2"> /// Input arrays. /// </param> /// <param name="x1"> /// Input arrays. /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Output array, element-wise comparison of x1 and x2. /// Typically of type bool, unless dtype=object is passed.<br></br> /// /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray not_equal(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.not_equal(x2, x1, @out: @out, @where: @where);
/// <summary> /// Returns a boolean array where two arrays are element-wise equal within a /// tolerance.<br></br> /// /// The tolerance values are positive, typically very small numbers.<br></br> /// The /// relative difference (rtol * abs(b)) and the absolute difference /// atol are added together to compare against the absolute difference /// between a and b.<br></br> /// /// Notes /// /// For finite values, isclose uses the following equation to test whether /// two floating point values are equivalent.<br></br> /// /// Unlike the built-in math.isclose, the above equation is not symmetric /// in a and b – it assumes b is the reference value – so that /// isclose(a, b) might be different from isclose(b, a).<br></br> /// Furthermore, /// the default value of atol is not zero, and is used to determine what /// small values should be considered close to zero.<br></br> /// The default value is /// appropriate for expected values of order unity: if the expected values /// are significantly smaller than one, it can result in false positives.<br></br> /// /// atol should be carefully selected for the use case at hand.<br></br> /// A zero value /// for atol will result in False if either a or b is zero. /// </summary> /// <param name="b"> /// Input arrays to compare. /// </param> /// <param name="a"> /// Input arrays to compare. /// </param> /// <param name="rtol"> /// The relative tolerance parameter (see Notes). /// </param> /// <param name="atol"> /// The absolute tolerance parameter (see Notes). /// </param> /// <param name="equal_nan"> /// Whether to compare NaN’s as equal.<br></br> /// If True, NaN’s in a will be /// considered equal to NaN’s in b in the output array. /// </param> /// <returns> /// Returns a boolean array of where a and b are equal within the /// given tolerance.<br></br> /// If both a and b are scalars, returns a single /// boolean value. /// </returns> public static NDarray isclose(NDarray b, NDarray a, float rtol = 1e-05f, float atol = 1e-08f, bool equal_nan = false) => NumPy.Instance.isclose(b, a, rtol: rtol, atol: atol, equal_nan: equal_nan);
/// <summary> /// Return the truth value of (x1 > x2) element-wise. /// </summary> /// <param name="x2"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="x1"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Output array, element-wise comparison of x1 and x2. /// Typically of type bool, unless dtype=object is passed.<br></br> /// /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray greater(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.greater(x2, x1, @out: @out, @where: @where);
/// <summary> /// Test element-wise for positive or negative infinity.<br></br> /// /// Returns a boolean array of the same shape as x, True where x == /// +/-inf, otherwise False.<br></br> /// /// Notes /// /// NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic /// (IEEE 754).<br></br> /// /// Errors result if the second argument is supplied when the first /// argument is a scalar, or if the first and second arguments have /// different shapes. /// </summary> /// <param name="x"> /// Input values /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// True where x is positive or negative infinity, false otherwise.<br></br> /// /// This is a scalar if x is a scalar. /// </returns> public static NDarray <bool> isinf(NDarray x, NDarray @out = null, NDarray @where = null) => NumPy.Instance.isinf(x, @out: @out, @where: @where);
/// <summary> /// Test element-wise for NaT (not a time) and return result as a boolean array. /// </summary> /// <param name="x"> /// Input array with datetime or timedelta data type. /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// True where x is NaT, false otherwise.<br></br> /// /// This is a scalar if x is a scalar. /// </returns> public static NDarray isnat(NDarray x, NDarray @out = null, NDarray @where = null) => NumPy.Instance.isnat(x, @out: @out, @where: @where);
/// <summary> /// Return the sum along diagonals of the array.<br></br> /// /// If a is 2-D, the sum along its diagonal with the given offset /// is returned, i.e., the sum of elements a[i,i+offset] for all i.<br></br> /// /// If a has more than two dimensions, then the axes specified by axis1 and /// axis2 are used to determine the 2-D sub-arrays whose traces are returned.<br></br> /// /// The shape of the resulting array is the same as that of a with axis1 /// and axis2 removed. /// </summary> /// <param name="a"> /// Input array, from which the diagonals are taken. /// </param> /// <param name="offset"> /// Offset of the diagonal from the main diagonal.<br></br> /// Can be both positive /// and negative.<br></br> /// Defaults to 0. /// </param> /// <param name="axis2"> /// Axes to be used as the first and second axis of the 2-D sub-arrays /// from which the diagonals should be taken.<br></br> /// Defaults are the first two /// axes of a. /// </param> /// <param name="axis1"> /// Axes to be used as the first and second axis of the 2-D sub-arrays /// from which the diagonals should be taken.<br></br> /// Defaults are the first two /// axes of a. /// </param> /// <param name="dtype"> /// Determines the data-type of the returned array and of the accumulator /// where the elements are summed.<br></br> /// If dtype has the value None and a is /// of integer type of precision less than the default integer /// precision, then the default integer precision is used.<br></br> /// Otherwise, /// the precision is the same as that of a. /// </param> /// <param name="out"> /// Array into which the output is placed.<br></br> /// Its type is preserved and /// it must be of the right shape to hold the output. /// </param> /// <returns> /// If a is 2-D, the sum along the diagonal is returned.<br></br> /// If a has /// larger dimensions, then an array of sums along diagonals is returned. /// </returns> public static NDarray trace(NDarray a, int?offset = 0, int?axis2 = null, int?axis1 = null, Dtype dtype = null, NDarray @out = null) { //auto-generated code, do not change var __self__ = self; var pyargs = ToTuple(new object[] { a, }); var kwargs = new PyDict(); if (offset != 0) { kwargs["offset"] = ToPython(offset); } if (axis2 != null) { kwargs["axis2"] = ToPython(axis2); } if (axis1 != null) { kwargs["axis1"] = ToPython(axis1); } if (dtype != null) { kwargs["dtype"] = ToPython(dtype); } if (@out != null) { kwargs["out"] = ToPython(@out); } dynamic py = __self__.InvokeMethod("trace", pyargs, kwargs); return(ToCsharp <NDarray>(py)); }
/// <summary> /// Test whether any array element along a given axis evaluates to True.<br></br> /// /// Returns single boolean unless axis is not None /// /// Notes /// /// Not a Number (NaN), positive infinity and negative infinity evaluate /// to True because these are not equal to zero. /// </summary> /// <param name="a"> /// Input array or object that can be converted to an array. /// </param> /// <returns> /// A new boolean or ndarray is returned unless out is specified, /// in which case a reference to out is returned. /// </returns> public static bool any(NDarray a) => NumPy.Instance.any(a);
/// <summary> /// Return the sum along diagonals of the array.<br></br> /// /// If a is 2-D, the sum along its diagonal with the given offset /// is returned, i.e., the sum of elements a[i,i+offset] for all i.<br></br> /// /// If a has more than two dimensions, then the axes specified by axis1 and /// axis2 are used to determine the 2-D sub-arrays whose traces are returned.<br></br> /// /// The shape of the resulting array is the same as that of a with axis1 /// and axis2 removed. /// </summary> /// <param name="a"> /// Input array, from which the diagonals are taken. /// </param> /// <param name="offset"> /// Offset of the diagonal from the main diagonal.<br></br> /// Can be both positive /// and negative.<br></br> /// Defaults to 0. /// </param> /// <param name="axis2"> /// Axes to be used as the first and second axis of the 2-D sub-arrays /// from which the diagonals should be taken.<br></br> /// Defaults are the first two /// axes of a. /// </param> /// <param name="axis1"> /// Axes to be used as the first and second axis of the 2-D sub-arrays /// from which the diagonals should be taken.<br></br> /// Defaults are the first two /// axes of a. /// </param> /// <param name="dtype"> /// Determines the data-type of the returned array and of the accumulator /// where the elements are summed.<br></br> /// If dtype has the value None and a is /// of integer type of precision less than the default integer /// precision, then the default integer precision is used.<br></br> /// Otherwise, /// the precision is the same as that of a. /// </param> /// <param name="out"> /// Array into which the output is placed.<br></br> /// Its type is preserved and /// it must be of the right shape to hold the output. /// </param> /// <returns> /// If a is 2-D, the sum along the diagonal is returned.<br></br> /// If a has /// larger dimensions, then an array of sums along diagonals is returned. /// </returns> public static NDarray trace(NDarray a, int?offset = 0, int?axis2 = null, int?axis1 = null, Dtype dtype = null, NDarray @out = null) => NumPy.Instance.trace(a, offset: offset, axis2: axis2, axis1: axis1, dtype: dtype, @out: @out);
/// <summary> /// Kronecker product of two arrays.<br></br> /// /// Computes the Kronecker product, a composite array made of blocks of the /// second array scaled by the first.<br></br> /// /// Notes /// /// The function assumes that the number of dimensions of a and b /// are the same, if necessary prepending the smallest with ones.<br></br> /// /// If a.shape = (r0,r1,..,rN) and b.shape = (s0,s1,…,sN), /// the Kronecker product has shape (r0*s0, r1*s1, …, rN*SN).<br></br> /// /// The elements are products of elements from a and b, organized /// explicitly by: /// /// where: /// /// In the common 2-D case (N=1), the block structure can be visualized: /// </summary> public static NDarray kron(NDarray b, NDarray a) => NumPy.Instance.kron(b, a);
/// <summary> /// Dot product of two arrays.<br></br> /// Specifically, /// </summary> /// <param name="a"> /// First argument. /// </param> /// <param name="b"> /// Second argument. /// </param> /// <param name="out"> /// Output argument.<br></br> /// This must have the exact kind that would be returned /// if it was not used.<br></br> /// In particular, it must have the right type, must be /// C-contiguous, and its dtype must be the dtype that would be returned /// for dot(a,b).<br></br> /// This is a performance feature.<br></br> /// Therefore, if these /// conditions are not met, an exception is raised, instead of attempting /// to be flexible. /// </param> /// <returns> /// Returns the dot product of a and b.<br></br> /// If a and b are both /// scalars or both 1-D arrays then a scalar is returned; otherwise /// an array is returned.<br></br> /// /// If out is given, then it is returned. /// </returns> public static NDarray dot(NDarray a, NDarray b, NDarray @out = null) => NumPy.Instance.dot(a, b, @out: @out);
/// <summary> /// Compute the truth value of x1 XOR x2, element-wise. /// </summary> /// <param name="x2"> /// Logical XOR is applied to the elements of x1 and x2. They must /// be broadcastable to the same shape. /// </param> /// <param name="x1"> /// Logical XOR is applied to the elements of x1 and x2. They must /// be broadcastable to the same shape. /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Boolean result of the logical XOR operation applied to the elements /// of x1 and x2; the shape is determined by whether or not /// broadcasting of one or both arrays was required.<br></br> /// /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray <bool> logical_xor(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.logical_xor(x2, x1, @out: @out, @where: @where);
/// <summary> /// Test element-wise for negative infinity, return result as bool array.<br></br> /// /// Notes /// /// NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic /// (IEEE 754).<br></br> /// /// Errors result if the second argument is also supplied when x is a scalar /// input, if first and second arguments have different shapes, or if the /// first argument has complex values. /// </summary> /// <param name="x"> /// The input array. /// </param> /// <param name="out"> /// A boolean array with the same shape and type as x to store the /// result. /// </param> /// <returns> /// A boolean array with the same dimensions as the input.<br></br> /// /// If second argument is not supplied then a numpy boolean array is /// returned with values True where the corresponding element of the /// input is negative infinity and values False where the element of /// the input is not negative infinity.<br></br> /// /// If a second argument is supplied the result is stored there.<br></br> /// If the /// type of that array is a numeric type the result is represented as /// zeros and ones, if the type is boolean then as False and True.<br></br> /// The /// return value out is then a reference to that array. /// </returns> public static NDarray isneginf(NDarray x, NDarray @out = null) => NumPy.Instance.isneginf(x, @out: @out);
/// <summary> /// Test whether all array elements along a given axis evaluate to True.<br></br> /// /// Notes /// /// Not a Number (NaN), positive infinity and negative infinity /// evaluate to True because these are not equal to zero. /// </summary> /// <param name="a"> /// Input array or object that can be converted to an array. /// </param> /// <param name="axis"> /// Axis or axes along which a logical AND reduction is performed.<br></br> /// /// The default (axis = None) is to perform a logical AND over all /// the dimensions of the input array.<br></br> /// axis may be negative, in /// which case it counts from the last to the first axis.<br></br> /// /// If this is a tuple of ints, a reduction is performed on multiple /// axes, instead of a single axis or all the axes as before. /// </param> /// <param name="out"> /// Alternate output array in which to place the result.<br></br> /// /// It must have the same shape as the expected output and its /// type is preserved (e.g., if dtype(out) is float, the result /// will consist of 0.0’s and 1.0’s).<br></br> /// See doc.ufuncs (Section /// “Output arguments”) for more details. /// </param> /// <param name="keepdims"> /// If this is set to True, the axes which are reduced are left /// in the result as dimensions with size one.<br></br> /// With this option, /// the result will broadcast correctly against the input array.<br></br> /// /// If the default value is passed, then keepdims will not be /// passed through to the all method of sub-classes of /// ndarray, however any non-default value will be.<br></br> /// If the /// sub-class’ method does not implement keepdims any /// exceptions will be raised. /// </param> /// <returns> /// A new boolean or array is returned unless out is specified, /// in which case a reference to out is returned. /// </returns> public static NDarray <bool> all(NDarray a, int[] axis, NDarray @out = null, bool?keepdims = null) => NumPy.Instance.all(a, axis: axis, @out: @out, keepdims: keepdims);
/// <summary> /// Test element-wise for positive infinity, return result as bool array.<br></br> /// /// Notes /// /// NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic /// (IEEE 754).<br></br> /// /// Errors result if the second argument is also supplied when x is a scalar /// input, if first and second arguments have different shapes, or if the /// first argument has complex values /// </summary> /// <param name="x"> /// The input array. /// </param> /// <param name="y"> /// A boolean array with the same shape as x to store the result. /// </param> /// <returns> /// A boolean array with the same dimensions as the input.<br></br> /// /// If second argument is not supplied then a boolean array is returned /// with values True where the corresponding element of the input is /// positive infinity and values False where the element of the input is /// not positive infinity.<br></br> /// /// If a second argument is supplied the result is stored there.<br></br> /// If the /// type of that array is a numeric type the result is represented as zeros /// and ones, if the type is boolean then as False and True.<br></br> /// /// The return value out is then a reference to that array. /// </returns> public static NDarray isposinf(NDarray x, NDarray y = null) => NumPy.Instance.isposinf(x, y: y);
/// <summary> /// Returns True if input arrays are shape consistent and all elements equal.<br></br> /// /// Shape consistent means they are either the same shape, or one input array /// can be broadcasted to create the same shape as the other one. /// </summary> /// <param name="a2"> /// Input arrays. /// </param> /// <param name="a1"> /// Input arrays. /// </param> /// <returns> /// True if equivalent, False otherwise. /// </returns> public static bool array_equiv(NDarray a2, NDarray a1) => NumPy.Instance.array_equiv(a2, a1);
/// <summary> /// Returns a bool array, where True if input element is complex.<br></br> /// /// What is tested is whether the input has a non-zero imaginary part, not if /// the input type is complex. /// </summary> /// <param name="x"> /// Input array. /// </param> /// <returns> /// Output array. /// </returns> public static NDarray iscomplex(NDarray x) => NumPy.Instance.iscomplex(x);
/// <summary> /// Return the truth value of (x1 >= x2) element-wise. /// </summary> /// <param name="x2"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="x1"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Output array, element-wise comparison of x1 and x2. /// Typically of type bool, unless dtype=object is passed.<br></br> /// /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray <bool> greater_equal(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.greater_equal(x2, x1, @out: @out, @where: @where);
/// <summary> /// Returns True if the array is Fortran contiguous but not C contiguous.<br></br> /// /// This function is obsolete and, because of changes due to relaxed stride /// checking, its return value for the same array may differ for versions /// of NumPy >= 1.10.0 and previous versions.<br></br> /// If you only want to check if an /// array is Fortran contiguous use a.flags.f_contiguous instead. /// </summary> /// <param name="a"> /// Input array. /// </param> public static bool isfortran(NDarray a) => NumPy.Instance.isfortran(a);
/// <summary> /// Return the truth value of (x1 < x2) element-wise. /// </summary> /// <param name="x2"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="x1"> /// Input arrays.<br></br> /// If x1.shape != x2.shape, they must be /// broadcastable to a common shape (which may be the shape of one or /// the other). /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Output array, element-wise comparison of x1 and x2. /// Typically of type bool, unless dtype=object is passed.<br></br> /// /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray less(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.less(x2, x1, @out: @out, @where: @where);
/// <summary> /// Returns a bool array, where True if input element is real.<br></br> /// /// If element has complex type with zero complex part, the return value /// for that element is True. /// </summary> /// <param name="x"> /// Input array. /// </param> /// <returns> /// Boolean array of same shape as x. /// </returns> public static NDarray isreal(NDarray x) => NumPy.Instance.isreal(x);
public NDarray(NDarray t) : base((PyObject)t.PyObject) { }
/// <summary> /// Compute the truth value of x1 AND x2 element-wise. /// </summary> /// <param name="x2"> /// Input arrays.<br></br> /// x1 and x2 must be of the same shape. /// </param> /// <param name="x1"> /// Input arrays.<br></br> /// x1 and x2 must be of the same shape. /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Boolean result with the same shape as x1 and x2 of the logical /// AND operation on corresponding elements of x1 and x2. /// This is a scalar if both x1 and x2 are scalars. /// </returns> public static NDarray logical_and(NDarray x2, NDarray x1, NDarray @out = null, NDarray @where = null) => NumPy.Instance.logical_and(x2, x1, @out: @out, @where: @where);
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static np.NDarray Slice(this np.NDarray array, string sliceNotation) { return(array[sliceNotation]); }
/// <summary> /// Compute the truth value of NOT x element-wise. /// </summary> /// <param name="x"> /// Logical NOT is applied to the elements of x. /// </param> /// <param name="out"> /// A location into which the result is stored.<br></br> /// If provided, it must have /// a shape that the inputs broadcast to.<br></br> /// If not provided or None, /// a freshly-allocated array is returned.<br></br> /// A tuple (possible only as a /// keyword argument) must have length equal to the number of outputs. /// </param> /// <param name="where"> /// Values of True indicate to calculate the ufunc at that position, values /// of False indicate to leave the value in the output alone. /// </param> /// <returns> /// Boolean result with the same shape as x of the NOT operation /// on elements of x.<br></br> /// /// This is a scalar if x is a scalar. /// </returns> public static NDarray <bool> logical_not(NDarray x, NDarray @out = null, NDarray @where = null) => NumPy.Instance.logical_not(x, @out: @out, @where: @where);
/***************************************************/ public static np.NDarray ISlice(this np.NDarray array, object[] slice) { return(array[slice as dynamic]); }
/// <summary> /// Compute tensor dot product along specified axes for arrays >= 1-D.<br></br> /// /// Given two tensors (arrays of dimension greater than or equal to one), /// a and b, and an array_like object containing two array_like /// objects, (a_axes, b_axes), sum the products of a’s and b’s /// elements (components) over the axes specified by a_axes and /// b_axes.<br></br> /// The third argument can be a single non-negative /// integer_like scalar, N; if it is such, then the last N /// dimensions of a and the first N dimensions of b are summed /// over.<br></br> /// /// Notes /// /// When axes is integer_like, the sequence for evaluation will be: first /// the -Nth axis in a and 0th axis in b, and the -1th axis in a and /// Nth axis in b last.<br></br> /// /// When there is more than one axis to sum over - and they are not the last /// (first) axes of a (b) - the argument axes should consist of /// two sequences of the same length, with the first axis to sum over given /// first in both sequences, the second axis second, and so forth. /// </summary> /// <param name="b"> /// Tensors to “dot”. /// </param> /// <param name="a"> /// Tensors to “dot”. /// </param> public static NDarray tensordot(NDarray b, NDarray a, int[] axes = null) => NumPy.Instance.tensordot(b, a, axes: axes);