Added iris classification example workflow as well as data type conversion nodes.

This commit is contained in:
HowToSD
2025-03-14 03:15:16 -07:00
parent 2d42cb24c0
commit 8fbecdfba9
42 changed files with 1670 additions and 1 deletions
+27
View File
@@ -89,11 +89,20 @@ from .modules.pytorch_wrapper.pt_sub import PtSub
from .modules.pytorch_wrapper.pt_sum import PtSum
from .modules.pytorch_wrapper.pt_tan import PtTan
from .modules.pytorch_wrapper.pt_tanh import PtTanh
from .modules.pytorch_wrapper.pt_to_bfloat16 import PtToBfloat16
from .modules.pytorch_wrapper.pt_to_float16 import PtToFloat16
from .modules.pytorch_wrapper.pt_to_float32 import PtToFloat32
from .modules.pytorch_wrapper.pt_to_float64 import PtToFloat64
from .modules.pytorch_wrapper.pt_to_image import PtToImage
from .modules.pytorch_wrapper.pt_to_image_transpose import PtToImageTranspose
from .modules.pytorch_wrapper.pt_to_int16 import PtToInt16
from .modules.pytorch_wrapper.pt_to_int32 import PtToInt32
from .modules.pytorch_wrapper.pt_to_int64 import PtToInt64
from .modules.pytorch_wrapper.pt_to_int8 import PtToInt8
from .modules.pytorch_wrapper.pt_to_latent import PtToLatent
from .modules.pytorch_wrapper.pt_to_numpy import PtToNumpy
from .modules.pytorch_wrapper.pt_to_rgb_tensors import PtToRgbTensors
from .modules.pytorch_wrapper.pt_to_uint8 import PtToUint8
from .modules.pytorch_wrapper.pt_train_classification_model import PtTrainClassificationModel
from .modules.pytorch_wrapper.pt_train_classification_model_lr import PtTrainClassificationModelLr
from .modules.pytorch_wrapper.pt_train_regression_model import PtTrainRegressionModel
@@ -216,11 +225,20 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
"PtSum": PtSum,
"PtTan": PtTan,
"PtTanh": PtTanh,
"PtToBfloat16": PtToBfloat16,
"PtToFloat16": PtToFloat16,
"PtToFloat32": PtToFloat32,
"PtToFloat64": PtToFloat64,
"PtToImage": PtToImage,
"PtToImageTranspose": PtToImageTranspose,
"PtToInt16": PtToInt16,
"PtToInt32": PtToInt32,
"PtToInt64": PtToInt64,
"PtToInt8": PtToInt8,
"PtToLatent": PtToLatent,
"PtToNumpy": PtToNumpy,
"PtToRgbTensors": PtToRgbTensors,
"PtToUint8": PtToUint8,
"PtTrainClassificationModel": PtTrainClassificationModel,
"PtTrainClassificationModelLr": PtTrainClassificationModelLr,
"PtTrainRegressionModel": PtTrainRegressionModel,
@@ -343,11 +361,20 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
"PtSum": "Pt Sum",
"PtTan": "Pt Tan",
"PtTanh": "Pt Tanh",
"PtToBfloat16": "Pt To Bfloat16",
"PtToFloat16": "Pt To Float16",
"PtToFloat32": "Pt To Float32",
"PtToFloat64": "Pt To Float64",
"PtToImage": "Pt To Image",
"PtToImageTranspose": "Pt To Image Transpose",
"PtToInt16": "Pt To Int16",
"PtToInt32": "Pt To Int32",
"PtToInt64": "Pt To Int64",
"PtToInt8": "Pt To Int8",
"PtToLatent": "Pt To Latent",
"PtToNumpy": "Pt To Numpy",
"PtToRgbTensors": "Pt To Rgb Tensors",
"PtToUint8": "Pt To Uint8",
"PtTrainClassificationModel": "Pt Train Classification Model",
"PtTrainClassificationModelLr": "Pt Train Classification Model Lr",
"PtTrainRegressionModel": "Pt Train Regression Model",
+8
View File
@@ -88,3 +88,11 @@ This workflow illustrates:
If you run training, you will notice that the loss remains in the 20s–30s instead of approaching 0, as you might expect.
Do you know why this happens?
# Using MLP for Small Dataset Classification
MLP can be used for small dataset classification.
Below is an example workflow for classifying the classic Iris dataset:
`examples/workflows/iris_classification_train_eval.json`.
According to [the UCI repository](https://archive.ics.uci.edu/dataset/53/iris), the neural network baseline accuracy for this dataset ranges from 92.105% to 100%. Using this workflow, you can expect around 96% accuracy, occasionally reaching 100%, which aligns with the baseline.
+12
View File
@@ -36,6 +36,18 @@
| [Pt Le](pt_le.md) | Tests whether elements in the first PyTorch tensor are less than or equal to the corresponding elements in the second tensor. |
| [Pt Lt](pt_lt.md) | Tests whether elements in the first PyTorch tensor are less than the corresponding elements in the second tensor. |
| [Pt Ne](pt_ne.md) | Tests whether two PyTorch tensors are not equal element-wise. |
## PyTorch wrapper - Data type conversion
| Node | Description |
| --- | --- |
| [Pt To Bfloat](pt_to_bfloat16.md) | Converts the input tensor's data type to bfloat16. |
| [Pt To Float](pt_to_float16.md) | Converts the input tensor's data type to float16. |
| [Pt To Float](pt_to_float32.md) | Converts the input tensor's data type to float32. |
| [Pt To Float](pt_to_float64.md) | Converts the input tensor's data type to float64. |
| [Pt To Int](pt_to_int16.md) | Converts the input tensor's data type to int16. |
| [Pt To Int](pt_to_int32.md) | Converts the input tensor's data type to int32. |
| [Pt To Int](pt_to_int64.md) | Converts the input tensor's data type to int64. |
| [Pt To Int](pt_to_int8.md) | Converts the input tensor's data type to int8. |
| [Pt To Uint](pt_to_uint8.md) | Converts the input tensor's data type to uint8. |
## PyTorch wrapper - Image processing
| Node | Description |
| --- | --- |
@@ -8,6 +8,11 @@ Performs inference on input data.
| inputs | Tensor |
| use_gpu | Boolean |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Training
+17
View File
@@ -0,0 +1,17 @@
# Pt To Bfloat
Converts the input tensor's data type to bfloat16.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Float
Converts the input tensor's data type to float16.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Float
Converts the input tensor's data type to float32.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Float
Converts the input tensor's data type to float64.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Int
Converts the input tensor's data type to int16.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Int
Converts the input tensor's data type to int32.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Int
Converts the input tensor's data type to int64.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Int
Converts the input tensor's data type to int8.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pt To Uint
Converts the input tensor's data type to uint8.
## Input
| Name | Data type |
|---|---|
| tens_a | Tensor |
## Output
| Data type |
|---|
| Tensor |
<HR>
Category: PyTorch wrapper - Data type conversion
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+5
View File
@@ -0,0 +1,5 @@
Index of iris
02 Dec 1996 105 Index
08 Mar 1993 4551 iris.data
30 May 1989 2604 iris.names
+151
View File
@@ -0,0 +1,151 @@
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.2,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.6,1.4,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica
+152
View File
@@ -0,0 +1,152 @@
sepal length,sepal width,petal length,petal width,class
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.2,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.6,1.4,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica
+151
View File
@@ -0,0 +1,151 @@
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica
+69
View File
@@ -0,0 +1,69 @@
1. Title: Iris Plants Database
Updated Sept 21 by C.Blake - Added discrepency information
2. Sources:
(a) Creator: R.A. Fisher
(b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
(c) Date: July, 1988
3. Past Usage:
- Publications: too many to mention!!! Here are a few.
1. Fisher,R.A. "The use of multiple measurements in taxonomic problems"
Annual Eugenics, 7, Part II, 179-188 (1936); also in "Contributions
to Mathematical Statistics" (John Wiley, NY, 1950).
2. Duda,R.O., & Hart,P.E. (1973) Pattern Classification and Scene Analysis.
(Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218.
3. Dasarathy, B.V. (1980) "Nosing Around the Neighborhood: A New System
Structure and Classification Rule for Recognition in Partially Exposed
Environments". IEEE Transactions on Pattern Analysis and Machine
Intelligence, Vol. PAMI-2, No. 1, 67-71.
-- Results:
-- very low misclassification rates (0% for the setosa class)
4. Gates, G.W. (1972) "The Reduced Nearest Neighbor Rule". IEEE
Transactions on Information Theory, May 1972, 431-433.
-- Results:
-- very low misclassification rates again
5. See also: 1988 MLC Proceedings, 54-64. Cheeseman et al's AUTOCLASS II
conceptual clustering system finds 3 classes in the data.
4. Relevant Information:
--- This is perhaps the best known database to be found in the pattern
recognition literature. Fisher's paper is a classic in the field
and is referenced frequently to this day. (See Duda & Hart, for
example.) The data set contains 3 classes of 50 instances each,
where each class refers to a type of iris plant. One class is
linearly separable from the other 2; the latter are NOT linearly
separable from each other.
--- Predicted attribute: class of iris plant.
--- This is an exceedingly simple domain.
--- This data differs from the data presented in Fishers article
(identified by Steve Chadwick, spchadwick@espeedaz.net )
The 35th sample should be: 4.9,3.1,1.5,0.2,"Iris-setosa"
where the error is in the fourth feature.
The 38th sample: 4.9,3.6,1.4,0.1,"Iris-setosa"
where the errors are in the second and third features.
5. Number of Instances: 150 (50 in each of three classes)
6. Number of Attributes: 4 numeric, predictive attributes and the class
7. Attribute Information:
1. sepal length in cm
2. sepal width in cm
3. petal length in cm
4. petal width in cm
5. class:
-- Iris Setosa
-- Iris Versicolour
-- Iris Virginica
8. Missing Attribute Values: None
Summary Statistics:
Min Max Mean SD Class Correlation
sepal length: 4.3 7.9 5.84 0.83 0.7826
sepal width: 2.0 4.4 3.05 0.43 -0.4194
petal length: 1.0 6.9 3.76 1.76 0.9490 (high!)
petal width: 0.1 2.5 1.20 0.76 0.9565 (high!)
9. Class Distribution: 33.3% for each of 3 classes.
+121
View File
@@ -0,0 +1,121 @@
,sepal length,sepal width,petal length,petal width,class
0,4.9,3.0,1.4,0.2,Iris-setosa
1,4.7,3.2,1.3,0.2,Iris-setosa
2,4.6,3.1,1.5,0.2,Iris-setosa
3,5.0,3.6,1.4,0.2,Iris-setosa
4,4.6,3.4,1.4,0.3,Iris-setosa
5,5.0,3.4,1.5,0.2,Iris-setosa
6,4.4,2.9,1.4,0.2,Iris-setosa
7,4.9,3.1,1.5,0.1,Iris-setosa
8,4.8,3.4,1.6,0.2,Iris-setosa
9,4.8,3.0,1.4,0.1,Iris-setosa
10,4.3,3.0,1.1,0.1,Iris-setosa
11,5.8,4.0,1.2,0.2,Iris-setosa
12,5.4,3.9,1.3,0.4,Iris-setosa
13,5.1,3.5,1.4,0.3,Iris-setosa
14,5.7,3.8,1.7,0.3,Iris-setosa
15,5.1,3.8,1.5,0.3,Iris-setosa
16,5.1,3.7,1.5,0.4,Iris-setosa
17,4.6,3.6,1.0,0.2,Iris-setosa
18,5.1,3.3,1.7,0.5,Iris-setosa
19,4.8,3.4,1.9,0.2,Iris-setosa
20,5.0,3.4,1.6,0.4,Iris-setosa
21,5.2,3.5,1.5,0.2,Iris-setosa
22,5.2,3.4,1.4,0.2,Iris-setosa
23,4.7,3.2,1.6,0.2,Iris-setosa
24,5.4,3.4,1.5,0.4,Iris-setosa
25,5.2,4.1,1.5,0.1,Iris-setosa
26,5.5,4.2,1.4,0.2,Iris-setosa
27,4.9,3.1,1.5,0.2,Iris-setosa
28,5.5,3.5,1.3,0.2,Iris-setosa
29,4.9,3.6,1.4,0.1,Iris-setosa
30,4.4,3.0,1.3,0.2,Iris-setosa
31,5.1,3.4,1.5,0.2,Iris-setosa
32,4.5,2.3,1.3,0.3,Iris-setosa
33,4.4,3.2,1.3,0.2,Iris-setosa
34,5.0,3.5,1.6,0.6,Iris-setosa
35,5.1,3.8,1.9,0.4,Iris-setosa
36,5.1,3.8,1.6,0.2,Iris-setosa
37,4.6,3.2,1.4,0.2,Iris-setosa
38,5.3,3.7,1.5,0.2,Iris-setosa
39,5.0,3.3,1.4,0.2,Iris-setosa
40,6.4,3.2,4.5,1.5,Iris-versicolor
41,6.9,3.1,4.9,1.5,Iris-versicolor
42,5.5,2.3,4.0,1.3,Iris-versicolor
43,6.5,2.8,4.6,1.5,Iris-versicolor
44,6.3,3.3,4.7,1.6,Iris-versicolor
45,4.9,2.4,3.3,1.0,Iris-versicolor
46,6.6,2.9,4.6,1.3,Iris-versicolor
47,5.2,2.7,3.9,1.4,Iris-versicolor
48,5.9,3.0,4.2,1.5,Iris-versicolor
49,6.0,2.2,4.0,1.0,Iris-versicolor
50,6.1,2.9,4.7,1.4,Iris-versicolor
51,5.6,2.9,3.6,1.3,Iris-versicolor
52,5.6,3.0,4.5,1.5,Iris-versicolor
53,5.8,2.7,4.1,1.0,Iris-versicolor
54,6.2,2.2,4.5,1.5,Iris-versicolor
55,5.6,2.5,3.9,1.1,Iris-versicolor
56,6.1,2.8,4.0,1.3,Iris-versicolor
57,6.3,2.5,4.9,1.5,Iris-versicolor
58,6.1,2.8,4.7,1.2,Iris-versicolor
59,6.4,2.9,4.3,1.3,Iris-versicolor
60,6.8,2.8,4.8,1.4,Iris-versicolor
61,6.7,3.0,5.0,1.7,Iris-versicolor
62,6.0,2.9,4.5,1.5,Iris-versicolor
63,5.7,2.6,3.5,1.0,Iris-versicolor
64,5.5,2.4,3.7,1.0,Iris-versicolor
65,5.8,2.7,3.9,1.2,Iris-versicolor
66,6.0,2.7,5.1,1.6,Iris-versicolor
67,5.4,3.0,4.5,1.5,Iris-versicolor
68,6.7,3.1,4.7,1.5,Iris-versicolor
69,6.3,2.3,4.4,1.3,Iris-versicolor
70,5.6,3.0,4.1,1.3,Iris-versicolor
71,5.5,2.5,4.0,1.3,Iris-versicolor
72,6.1,3.0,4.6,1.4,Iris-versicolor
73,5.8,2.6,4.0,1.2,Iris-versicolor
74,5.0,2.3,3.3,1.0,Iris-versicolor
75,5.6,2.7,4.2,1.3,Iris-versicolor
76,5.7,2.9,4.2,1.3,Iris-versicolor
77,6.2,2.9,4.3,1.3,Iris-versicolor
78,5.1,2.5,3.0,1.1,Iris-versicolor
79,5.7,2.8,4.1,1.3,Iris-versicolor
80,5.8,2.7,5.1,1.9,Iris-virginica
81,7.1,3.0,5.9,2.1,Iris-virginica
82,6.3,2.9,5.6,1.8,Iris-virginica
83,6.5,3.0,5.8,2.2,Iris-virginica
84,4.9,2.5,4.5,1.7,Iris-virginica
85,7.3,2.9,6.3,1.8,Iris-virginica
86,6.7,2.5,5.8,1.8,Iris-virginica
87,7.2,3.6,6.1,2.5,Iris-virginica
88,6.4,2.7,5.3,1.9,Iris-virginica
89,6.8,3.0,5.5,2.1,Iris-virginica
90,5.7,2.5,5.0,2.0,Iris-virginica
91,5.8,2.8,5.1,2.4,Iris-virginica
92,6.5,3.0,5.5,1.8,Iris-virginica
93,7.7,3.8,6.7,2.2,Iris-virginica
94,7.7,2.6,6.9,2.3,Iris-virginica
95,6.0,2.2,5.0,1.5,Iris-virginica
96,5.6,2.8,4.9,2.0,Iris-virginica
97,7.7,2.8,6.7,2.0,Iris-virginica
98,6.3,2.7,4.9,1.8,Iris-virginica
99,6.7,3.3,5.7,2.1,Iris-virginica
100,6.2,2.8,4.8,1.8,Iris-virginica
101,6.1,3.0,4.9,1.8,Iris-virginica
102,6.4,2.8,5.6,2.1,Iris-virginica
103,7.2,3.0,5.8,1.6,Iris-virginica
104,7.9,3.8,6.4,2.0,Iris-virginica
105,6.4,2.8,5.6,2.2,Iris-virginica
106,6.3,2.8,5.1,1.5,Iris-virginica
107,6.1,2.6,5.6,1.4,Iris-virginica
108,6.3,3.4,5.6,2.4,Iris-virginica
109,6.4,3.1,5.5,1.8,Iris-virginica
110,6.0,3.0,4.8,1.8,Iris-virginica
111,6.9,3.1,5.4,2.1,Iris-virginica
112,6.9,3.1,5.1,2.3,Iris-virginica
113,5.8,2.7,5.1,1.9,Iris-virginica
114,6.8,3.2,5.9,2.3,Iris-virginica
115,6.7,3.3,5.7,2.5,Iris-virginica
116,6.3,2.5,5.0,1.9,Iris-virginica
117,6.5,3.0,5.2,2.0,Iris-virginica
118,6.2,3.4,5.4,2.3,Iris-virginica
119,5.9,3.0,5.1,1.8,Iris-virginica
1 sepal length sepal width petal length petal width class
2 0 4.9 3.0 1.4 0.2 Iris-setosa
3 1 4.7 3.2 1.3 0.2 Iris-setosa
4 2 4.6 3.1 1.5 0.2 Iris-setosa
5 3 5.0 3.6 1.4 0.2 Iris-setosa
6 4 4.6 3.4 1.4 0.3 Iris-setosa
7 5 5.0 3.4 1.5 0.2 Iris-setosa
8 6 4.4 2.9 1.4 0.2 Iris-setosa
9 7 4.9 3.1 1.5 0.1 Iris-setosa
10 8 4.8 3.4 1.6 0.2 Iris-setosa
11 9 4.8 3.0 1.4 0.1 Iris-setosa
12 10 4.3 3.0 1.1 0.1 Iris-setosa
13 11 5.8 4.0 1.2 0.2 Iris-setosa
14 12 5.4 3.9 1.3 0.4 Iris-setosa
15 13 5.1 3.5 1.4 0.3 Iris-setosa
16 14 5.7 3.8 1.7 0.3 Iris-setosa
17 15 5.1 3.8 1.5 0.3 Iris-setosa
18 16 5.1 3.7 1.5 0.4 Iris-setosa
19 17 4.6 3.6 1.0 0.2 Iris-setosa
20 18 5.1 3.3 1.7 0.5 Iris-setosa
21 19 4.8 3.4 1.9 0.2 Iris-setosa
22 20 5.0 3.4 1.6 0.4 Iris-setosa
23 21 5.2 3.5 1.5 0.2 Iris-setosa
24 22 5.2 3.4 1.4 0.2 Iris-setosa
25 23 4.7 3.2 1.6 0.2 Iris-setosa
26 24 5.4 3.4 1.5 0.4 Iris-setosa
27 25 5.2 4.1 1.5 0.1 Iris-setosa
28 26 5.5 4.2 1.4 0.2 Iris-setosa
29 27 4.9 3.1 1.5 0.2 Iris-setosa
30 28 5.5 3.5 1.3 0.2 Iris-setosa
31 29 4.9 3.6 1.4 0.1 Iris-setosa
32 30 4.4 3.0 1.3 0.2 Iris-setosa
33 31 5.1 3.4 1.5 0.2 Iris-setosa
34 32 4.5 2.3 1.3 0.3 Iris-setosa
35 33 4.4 3.2 1.3 0.2 Iris-setosa
36 34 5.0 3.5 1.6 0.6 Iris-setosa
37 35 5.1 3.8 1.9 0.4 Iris-setosa
38 36 5.1 3.8 1.6 0.2 Iris-setosa
39 37 4.6 3.2 1.4 0.2 Iris-setosa
40 38 5.3 3.7 1.5 0.2 Iris-setosa
41 39 5.0 3.3 1.4 0.2 Iris-setosa
42 40 6.4 3.2 4.5 1.5 Iris-versicolor
43 41 6.9 3.1 4.9 1.5 Iris-versicolor
44 42 5.5 2.3 4.0 1.3 Iris-versicolor
45 43 6.5 2.8 4.6 1.5 Iris-versicolor
46 44 6.3 3.3 4.7 1.6 Iris-versicolor
47 45 4.9 2.4 3.3 1.0 Iris-versicolor
48 46 6.6 2.9 4.6 1.3 Iris-versicolor
49 47 5.2 2.7 3.9 1.4 Iris-versicolor
50 48 5.9 3.0 4.2 1.5 Iris-versicolor
51 49 6.0 2.2 4.0 1.0 Iris-versicolor
52 50 6.1 2.9 4.7 1.4 Iris-versicolor
53 51 5.6 2.9 3.6 1.3 Iris-versicolor
54 52 5.6 3.0 4.5 1.5 Iris-versicolor
55 53 5.8 2.7 4.1 1.0 Iris-versicolor
56 54 6.2 2.2 4.5 1.5 Iris-versicolor
57 55 5.6 2.5 3.9 1.1 Iris-versicolor
58 56 6.1 2.8 4.0 1.3 Iris-versicolor
59 57 6.3 2.5 4.9 1.5 Iris-versicolor
60 58 6.1 2.8 4.7 1.2 Iris-versicolor
61 59 6.4 2.9 4.3 1.3 Iris-versicolor
62 60 6.8 2.8 4.8 1.4 Iris-versicolor
63 61 6.7 3.0 5.0 1.7 Iris-versicolor
64 62 6.0 2.9 4.5 1.5 Iris-versicolor
65 63 5.7 2.6 3.5 1.0 Iris-versicolor
66 64 5.5 2.4 3.7 1.0 Iris-versicolor
67 65 5.8 2.7 3.9 1.2 Iris-versicolor
68 66 6.0 2.7 5.1 1.6 Iris-versicolor
69 67 5.4 3.0 4.5 1.5 Iris-versicolor
70 68 6.7 3.1 4.7 1.5 Iris-versicolor
71 69 6.3 2.3 4.4 1.3 Iris-versicolor
72 70 5.6 3.0 4.1 1.3 Iris-versicolor
73 71 5.5 2.5 4.0 1.3 Iris-versicolor
74 72 6.1 3.0 4.6 1.4 Iris-versicolor
75 73 5.8 2.6 4.0 1.2 Iris-versicolor
76 74 5.0 2.3 3.3 1.0 Iris-versicolor
77 75 5.6 2.7 4.2 1.3 Iris-versicolor
78 76 5.7 2.9 4.2 1.3 Iris-versicolor
79 77 6.2 2.9 4.3 1.3 Iris-versicolor
80 78 5.1 2.5 3.0 1.1 Iris-versicolor
81 79 5.7 2.8 4.1 1.3 Iris-versicolor
82 80 5.8 2.7 5.1 1.9 Iris-virginica
83 81 7.1 3.0 5.9 2.1 Iris-virginica
84 82 6.3 2.9 5.6 1.8 Iris-virginica
85 83 6.5 3.0 5.8 2.2 Iris-virginica
86 84 4.9 2.5 4.5 1.7 Iris-virginica
87 85 7.3 2.9 6.3 1.8 Iris-virginica
88 86 6.7 2.5 5.8 1.8 Iris-virginica
89 87 7.2 3.6 6.1 2.5 Iris-virginica
90 88 6.4 2.7 5.3 1.9 Iris-virginica
91 89 6.8 3.0 5.5 2.1 Iris-virginica
92 90 5.7 2.5 5.0 2.0 Iris-virginica
93 91 5.8 2.8 5.1 2.4 Iris-virginica
94 92 6.5 3.0 5.5 1.8 Iris-virginica
95 93 7.7 3.8 6.7 2.2 Iris-virginica
96 94 7.7 2.6 6.9 2.3 Iris-virginica
97 95 6.0 2.2 5.0 1.5 Iris-virginica
98 96 5.6 2.8 4.9 2.0 Iris-virginica
99 97 7.7 2.8 6.7 2.0 Iris-virginica
100 98 6.3 2.7 4.9 1.8 Iris-virginica
101 99 6.7 3.3 5.7 2.1 Iris-virginica
102 100 6.2 2.8 4.8 1.8 Iris-virginica
103 101 6.1 3.0 4.9 1.8 Iris-virginica
104 102 6.4 2.8 5.6 2.1 Iris-virginica
105 103 7.2 3.0 5.8 1.6 Iris-virginica
106 104 7.9 3.8 6.4 2.0 Iris-virginica
107 105 6.4 2.8 5.6 2.2 Iris-virginica
108 106 6.3 2.8 5.1 1.5 Iris-virginica
109 107 6.1 2.6 5.6 1.4 Iris-virginica
110 108 6.3 3.4 5.6 2.4 Iris-virginica
111 109 6.4 3.1 5.5 1.8 Iris-virginica
112 110 6.0 3.0 4.8 1.8 Iris-virginica
113 111 6.9 3.1 5.4 2.1 Iris-virginica
114 112 6.9 3.1 5.1 2.3 Iris-virginica
115 113 5.8 2.7 5.1 1.9 Iris-virginica
116 114 6.8 3.2 5.9 2.3 Iris-virginica
117 115 6.7 3.3 5.7 2.5 Iris-virginica
118 116 6.3 2.5 5.0 1.9 Iris-virginica
119 117 6.5 3.0 5.2 2.0 Iris-virginica
120 118 6.2 3.4 5.4 2.3 Iris-virginica
121 119 5.9 3.0 5.1 1.8 Iris-virginica
+31
View File
@@ -0,0 +1,31 @@
,sepal length,sepal width,petal length,petal width,class
0,5.1,3.5,1.4,0.2,Iris-setosa
1,5.4,3.9,1.7,0.4,Iris-setosa
2,5.4,3.7,1.5,0.2,Iris-setosa
3,5.7,4.4,1.5,0.4,Iris-setosa
4,5.4,3.4,1.7,0.2,Iris-setosa
5,5.0,3.0,1.6,0.2,Iris-setosa
6,4.8,3.1,1.6,0.2,Iris-setosa
7,5.0,3.2,1.2,0.2,Iris-setosa
8,5.0,3.5,1.3,0.3,Iris-setosa
9,4.8,3.0,1.4,0.3,Iris-setosa
10,7.0,3.2,4.7,1.4,Iris-versicolor
11,5.7,2.8,4.5,1.3,Iris-versicolor
12,5.0,2.0,3.5,1.0,Iris-versicolor
13,6.7,3.1,4.4,1.4,Iris-versicolor
14,5.9,3.2,4.8,1.8,Iris-versicolor
15,6.6,3.0,4.4,1.4,Iris-versicolor
16,5.5,2.4,3.8,1.1,Iris-versicolor
17,6.0,3.4,4.5,1.6,Iris-versicolor
18,5.5,2.6,4.4,1.2,Iris-versicolor
19,5.7,3.0,4.2,1.2,Iris-versicolor
20,6.3,3.3,6.0,2.5,Iris-virginica
21,7.6,3.0,6.6,2.1,Iris-virginica
22,6.5,3.2,5.1,2.0,Iris-virginica
23,6.4,3.2,5.3,2.3,Iris-virginica
24,6.9,3.2,5.7,2.3,Iris-virginica
25,7.2,3.2,6.0,1.8,Iris-virginica
26,7.4,2.8,6.1,1.9,Iris-virginica
27,7.7,3.0,6.1,2.3,Iris-virginica
28,6.7,3.1,5.6,2.4,Iris-virginica
29,6.7,3.0,5.2,2.3,Iris-virginica
1 sepal length sepal width petal length petal width class
2 0 5.1 3.5 1.4 0.2 Iris-setosa
3 1 5.4 3.9 1.7 0.4 Iris-setosa
4 2 5.4 3.7 1.5 0.2 Iris-setosa
5 3 5.7 4.4 1.5 0.4 Iris-setosa
6 4 5.4 3.4 1.7 0.2 Iris-setosa
7 5 5.0 3.0 1.6 0.2 Iris-setosa
8 6 4.8 3.1 1.6 0.2 Iris-setosa
9 7 5.0 3.2 1.2 0.2 Iris-setosa
10 8 5.0 3.5 1.3 0.3 Iris-setosa
11 9 4.8 3.0 1.4 0.3 Iris-setosa
12 10 7.0 3.2 4.7 1.4 Iris-versicolor
13 11 5.7 2.8 4.5 1.3 Iris-versicolor
14 12 5.0 2.0 3.5 1.0 Iris-versicolor
15 13 6.7 3.1 4.4 1.4 Iris-versicolor
16 14 5.9 3.2 4.8 1.8 Iris-versicolor
17 15 6.6 3.0 4.4 1.4 Iris-versicolor
18 16 5.5 2.4 3.8 1.1 Iris-versicolor
19 17 6.0 3.4 4.5 1.6 Iris-versicolor
20 18 5.5 2.6 4.4 1.2 Iris-versicolor
21 19 5.7 3.0 4.2 1.2 Iris-versicolor
22 20 6.3 3.3 6.0 2.5 Iris-virginica
23 21 7.6 3.0 6.6 2.1 Iris-virginica
24 22 6.5 3.2 5.1 2.0 Iris-virginica
25 23 6.4 3.2 5.3 2.3 Iris-virginica
26 24 6.9 3.2 5.7 2.3 Iris-virginica
27 25 7.2 3.2 6.0 1.8 Iris-virginica
28 26 7.4 2.8 6.1 1.9 Iris-virginica
29 27 7.7 3.0 6.1 2.3 Iris-virginica
30 28 6.7 3.1 5.6 2.4 Iris-virginica
31 29 6.7 3.0 5.2 2.3 Iris-virginica
+18
View File
@@ -0,0 +1,18 @@
# Iris Data License
Iris data downloaded from [UCI Machine Learning Repository](https://archive.ics.uci.edu/dataset/53/iris), originally from **R.A. Fisher**.
This dataset is licensed under a [Creative Commons Attribution 4.0 International (CC BY 4.0) license](https://creativecommons.org/licenses/by/4.0/legalcode).
bedzekIris.data contains data what was identiefed as correct. Please see this article: https://lucykuncheva.co.uk/papers/jbjkrklknptfs99.pdf
```
diff bezdekIris.data iris.data
35c35
< 4.9,3.1,1.5,0.2,Iris-setosa
---
> 4.9,3.1,1.5,0.1,Iris-setosa
38c38
< 4.9,3.6,1.4,0.1,Iris-setosa
---
> 4.9,3.1,1.5,0.1,Iris-setosa
```
+45
View File
@@ -0,0 +1,45 @@
"""
Train val split by HowToSD
"""
import os
import sys
import pandas as pd
def main():
target_file_path = os.path.join(os.path.dirname(__file__), "bezdekIris_with_header.data")
df = pd.read_csv(target_file_path)
# Split to 3 dfs
df1 = df.query('`class`=="Iris-setosa"')
df2 = df.query('`class`=="Iris-versicolor"')
df3 = df.query('`class`=="Iris-virginica"')
assert len(df1) == 50
assert len(df2) == 50
assert len(df3) == 50
train_indices = []
val_indices = []
# Train/validation split indices (20% validation)
val_indices = list(range(0, 50, 5)) # [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]
train_indices = list(set(range(50)) - set(val_indices))
# Apply train/val split
df1_train, df1_val = df1.iloc[train_indices], df1.iloc[val_indices]
df2_train, df2_val = df2.iloc[train_indices], df2.iloc[val_indices]
df3_train, df3_val = df3.iloc[train_indices], df3.iloc[val_indices]
# Concatenate all train and val datasets
df_train = pd.concat([df1_train, df2_train, df3_train], ignore_index=True)
df_val = pd.concat([df1_val, df2_val, df3_val], ignore_index=True)
# Check dataset sizes
assert len(df_train) == 120
assert len(df_val) == 30
df_train.to_csv(os.path.join(os.path.dirname(__file__), "iris_train.csv"))
df_val.to_csv(os.path.join(os.path.dirname(__file__), "iris_val.csv"))
if __name__ == "__main__":
main()
File diff suppressed because one or more lines are too long
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToBfloat16:
"""
Converts the input tensor's data type to bfloat16.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to bfloat16.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.bfloat16),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToFloat16:
"""
Converts the input tensor's data type to float16.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to float16.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.float16),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToFloat32:
"""
Converts the input tensor's data type to float32.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to float32.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.float32),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToFloat64:
"""
Converts the input tensor's data type to float64.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to float64.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.float64),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToInt16:
"""
Converts the input tensor's data type to int16.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to int16.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.int16),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToInt32:
"""
Converts the input tensor's data type to int32.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to int32.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.int32),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToInt64:
"""
Converts the input tensor's data type to int64.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to int64.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.int64),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToInt8:
"""
Converts the input tensor's data type to int8.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to int8.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.int8),)
+39
View File
@@ -0,0 +1,39 @@
from typing import Any, Dict
import torch
class PtToUint8:
"""
Converts the input tensor's data type to uint8.
category: PyTorch wrapper - Data type conversion
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the required input types.
Returns:
Dict[str, Any]: A dictionary of required input types.
"""
return {
"required": {
"tens_a": ("TENSOR", {})
}
}
RETURN_TYPES: tuple = ("TENSOR",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens_a: torch.Tensor) -> tuple:
"""
Converts the input tensor's data type to uint8.
Args:
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
Returns:
tuple: A tuple containing the resultant tensor after the operation.
"""
return (tens_a.to(torch.uint8),)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "pt-wrapper"
description = "PyTorch extension for ComfyUI featuring extensive PyTorch wrapper nodes for seamless tensor operations and PyTorch model training."
version = "3.0.8"
version = "3.0.9"
license = {file = "LICENSE"}
[project.urls]
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_bfloat16 import PtToBfloat16
class TestPtToFloat16(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToBfloat16()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16), torch.tensor([1.0, 2.0, 3.0], dtype=torch.bfloat16), torch.bfloat16),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_float16 import PtToFloat16
class TestPtToFloat16(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToFloat16()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16), torch.float16),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_float32 import PtToFloat32
class TestPtToFloat32(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToFloat32()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16), torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.float32),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_float64 import PtToFloat64
class TestPtToFloat64(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToFloat64()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16), torch.tensor([1.0, 2.0, 3.0], dtype=torch.float64), torch.float64),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_int16 import PtToInt16
class TestPtToInt16(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToInt16()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1, 2, 3], dtype=torch.int16), torch.int16),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_int32 import PtToInt32
class TestPtToInt32(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToInt32()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1, 2, 3], dtype=torch.int32), torch.int32),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_int64 import PtToInt64
class TestPtToInt64(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToInt64()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1, 2, 3], dtype=torch.int64), torch.int64),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_int8 import PtToInt8
class TestPtToInt8(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToInt8()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1, 2, 3], dtype=torch.int8), torch.int8),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
import os
import sys
import unittest
import torch
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
sys.path.append(MODULE_ROOT)
from pytorch_wrapper.pt_to_uint8 import PtToUint8
class TestPtToUint8(unittest.TestCase):
def setUp(self):
"""Set up test instance."""
self.node = PtToUint8()
# Test cases: (Tensor A, expected result, expected dtype)
self.test_cases = [
(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32), torch.tensor([1, 2, 3], dtype=torch.uint8), torch.uint8),
]
def test_1(self):
"""Test tensor element-wise square root using torch.sqrt()."""
for tens_a, expected_value, expected_dtype in self.test_cases:
with self.subTest(tens_a=tens_a):
result, = self.node.f(tens_a)
# Ensure return value is a tensor
self.assertTrue(isinstance(result, torch.Tensor), "Output is not a tensor")
# Ensure data type
self.assertEqual(result.dtype, expected_dtype,
f"Expected dtype {expected_dtype}, got {result.dtype}")
# Ensure result matches expected values
self.assertTrue(torch.allclose(result, expected_value, atol=1e-6), f"Expected {expected_value}, got {result}")
if __name__ == "__main__":
unittest.main()