///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(long data, dtype dtype = torch.dtype.int64, bool requires_grad = false) { var result = new Tensor(new long[] { data }, dtype, requires_grad); result.__ndim = 0; return(result); }
public static PyObject ToPython(this dtype value) { var torch = PyTorch.Instance.self; // todo: cache these values switch (value) { case dtype.UInt8: return((PyObject)torch.uint8); case dtype.Int8: return((PyObject)torch.int8); case dtype.Int16: return((PyObject)torch.int16); case dtype.Int32: return((PyObject)torch.int32); case dtype.Int64: return((PyObject)torch.int64); //case dtype.Float16: return (PyObject)torch.float16; case dtype.Float32: return((PyObject)torch.float32); case dtype.Float64: return((PyObject)torch.float64); default: throw new ArgumentException("Invalid dtype: " + value); } }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(bool data, dtype dtype = torch.dtype.@bool, bool requires_grad = false) { var result = new Tensor(new bool[] { data }, dtype, requires_grad); result.__ndim = 0; return(result); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(double data, dtype dtype = torch.dtype.float64, bool requires_grad = false) { var result = new Tensor(new double[] { data }, dtype, requires_grad); result.__ndim = 0; return(result); }
public static ndarray ToCategorial(ndarray y, int?num_classes = null, dtype dtype = null) { var input_shape = y.shape; List <long> new_shape = new List <long>(); if (input_shape.lastDim == 1 && input_shape.iDims.Length > 1) { new_shape = input_shape.iDims.Take(input_shape.iDims.Length - 1).ToList(); } else { new_shape = input_shape.iDims.ToList(); } y = y.ravel(); if (num_classes.HasValue) { num_classes = (int)np.max(y) + 1; } var n = y.shape.iDims[0]; var categorical = np.zeros((n, num_classes), dtype: dtype); categorical[np.arange(n), y] = 1; new_shape.Add(num_classes.Value); var output_shape = new shape(new_shape); categorical = np.reshape(categorical, output_shape); return(categorical); }
///<summary>Returns a tensor filled with the scalar value 0, with the same size as input.</summary> ///<param name = "input">The size of input will determine size of the output tensor.</param> ///<param name = "dtype">The desired data type of returned Tensor. Default: if default, defaults to the dtype of input.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public Tensor zeros_like(dtype dtype = dtype.@default, bool requires_grad = false) { if ((this.dtype == dtype.@bool) || (dtype == dtype.@bool)) { throw new torch.TorchException("TorchException: zeros_like() is not supported for Boolean tensors."); } var result = new Tensor(this.size(), (dtype == dtype.@default) ? this.dtype : dtype, requires_grad); return(result); }
///<summary>Specifies the required default data type.</summary> public static void set_default_tensor_type(dtype dtype) { if (default_dtype == dtype) { __Warnings.warn("The current default data type is the same as the required one."); } else { default_dtype = dtype; } }
void GetData(dtype t) { try { object ob = null; using (SQLiteConnection conn = new SQLiteConnection(config.DataSource)) { using (SQLiteCommand cmd = new SQLiteCommand()) { conn.Open(); cmd.Connection = conn; SQLiteHelper sh = new SQLiteHelper(cmd); switch (t) { case dtype.text: ob = sh.ExecuteScalar <string>("select 'Hello!';"); break; case dtype.integer: ob = sh.ExecuteScalar <int>("select 1000;"); break; case dtype.datetime: ob = sh.ExecuteScalar <DateTime>("select date('now');"); break; case dtype.dec: ob = sh.ExecuteScalar <decimal>("select 4.4;"); break; case dtype.blob: ob = sh.ExecuteScalar <byte[]>("select randomblob(16);"); break; default: break; } conn.Close(); } } MessageBox.Show("Type: " + ob.GetType() + Environment.NewLine + "Value: " + ob.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public NumpyArrayIterator(ndarray x, ndarray y, ImageDataGenerator image_data_generator, int batch_size = 32, bool shuffle = false, ndarray sample_weight = null, int?seed = null, string data_format = "channels_last", string save_to_dir = "", string save_prefix = "", string save_format = "png", string subset = "", dtype dtype = null) : base((int)x.shape.iDims[0], batch_size, shuffle, seed) { }
private void defaultDiagram(dtype type = dtype.XY) { _type = type; if (_type == dtype.XY) { _p0 = new Point(0, _size.Height); } else if (_type == dtype.Center) { _p0 = new Point(_size.Width / 2, _size.Height / 2); drawDiagram(); } //_type = type; //Size size = new Size(1, 1); //if (_pbox != null) size = _pbox.Size; //else if (_form != null) size = _form.ClientSize; //if (_type == dtype.XY) { _p0 = new Point(0, size.Height); } //else if (_type == dtype.Center) { _p0 = new Point(size.Width / 2, size.Height / 2); } }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(byte w, byte h, byte d, byte t, byte b, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size(w, h, d, t, b), dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(int w, int h, int d, int t, int b, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size(w, h, d, t, b), dtype, requires_grad)); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(bool[,,,,] data, dtype dtype = torch.dtype.@bool, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(long[,,] data, dtype dtype = torch.dtype.int64, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(short[,] data, dtype dtype = torch.dtype.int16, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(long w, long h, long d, long t, long b, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size((int)w, (int)h, (int)d, (int)t, (int)b), dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 1, with the same size as input.</summary> ///<param name = "input">The size of input will determine size of the output tensor.</param> ///<param name = "dtype">The desired data type of returned Tensor. Default: if default, defaults to the dtype of input.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public Tensor ones_like(dtype dtype = dtype.@default, bool requires_grad = false) { var result = new Tensor(this.size(), (dtype == dtype.@default) ? this.dtype : dtype, requires_grad); switch (result.dtype) { case torch.dtype.float16: { for (int i = 0; i < result.__data_float16.Length; i++) { result.__data_float16[i] = 1; } break; } case torch.dtype.float32: { for (int i = 0; i < result.__data_float32.Length; i++) { result.__data_float32[i] = 1; } break; } case torch.dtype.float64: { for (int i = 0; i < result.__data_float64.Length; i++) { result.__data_float64[i] = 1; } break; } case torch.dtype.int8: { for (int i = 0; i < result.__data_int8.Length; i++) { result.__data_int8[i] = 1; } break; } case torch.dtype.uint8: { for (int i = 0; i < result.__data_uint8.Length; i++) { result.__data_uint8[i] = 1; } break; } case torch.dtype.int16: { for (int i = 0; i < result.__data_int16.Length; i++) { result.__data_int16[i] = 1; } break; } case torch.dtype.int32: { for (int i = 0; i < result.__data_int32.Length; i++) { result.__data_int32[i] = 1; } break; } case torch.dtype.int64: { for (int i = 0; i < result.__data_int64.Length; i++) { result.__data_int64[i] = 1; } break; } case torch.dtype.@bool: { throw new torch.TorchException("TorchException: ones_like is not supported for Boolean tensors."); } } return(result); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(Half[,,,,] data, dtype dtype = torch.dtype.float16, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
public myDiagram(dtype type, Graphics g, Size size) { _g = g; _size = size; defaultDiagram(type); }
///<summary>Sets the default library settings.</summary> static torch() { default_dtype = dtype.float32; warnings_are_enabled = true; library_info = "Torch.NET ver. 0.1 -> build 02.11.2019"; }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(Tuple <long, long, long, long, long> size, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size((int)size.Item1, (int)size.Item2, (int)size.Item3, (int)size.Item4, (int)size.Item5), dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(Tuple <int, int, int, int, int> size, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size(size.Item1, size.Item2, size.Item3, size.Item4, size.Item5), dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(Tuple <byte, byte> size, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size(size.Item1, size.Item2), dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the same size as input.</summary> ///<param name = "input">The size of input will determine size of the output tensor.</param> ///<param name = "dtype">The desired data type of returned Tensor. Default: if default, defaults to the dtype of input.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor zeros_like(Tensor input, dtype dtype = dtype.@default, bool requires_grad = false) { return(input.zeros_like(dtype, requires_grad)); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(double[,] data, dtype dtype = torch.dtype.float64, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
public static ndarray ToCategorial(ndarray y, int?num_classes = null, dtype dtype = null) { throw new NotImplementedException(); }
///<summary>Constructs a tensor with data.</summary> ///<param name = "data">Initial data for the tensor.</param> ///<param name = "dtype">The desired data type of returned tensor. Default: if not passed, infers data type from data.</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: false.</param> public static Tensor tensor(byte[,] data, dtype dtype = torch.dtype.uint8, bool requires_grad = false) { return(new Tensor(data, dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(Size size, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(size, dtype, requires_grad)); }
///<summary>Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.</summary> ///<param name = "size">A sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.</param> ///<param name = "dtype">the desired data type of returned tensor. Default: if None, uses a global default(see torch.set_default_tensor_type()).</param> ///<param name = "requires_grad">If autograd should record operations on the returned tensor. Default: False.</param> public static Tensor zeros(long w, dtype dtype = dtype.@default, bool requires_grad = false) { return(new Tensor(new Size((int)w), dtype, requires_grad)); }