Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): update ormbfile struct #150

Merged
merged 6 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions docs/docs_zh/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ spec:
"value": "0.928"
}
],
"hyperparameters": [
"hyperParameters": [
{
"name": "batch_size",
"value": "32"
Expand All @@ -298,7 +298,7 @@ spec:
224,
3
],
"dtype": "float64",
"dType": "float64",
}
],
"outputs": [
Expand All @@ -308,14 +308,12 @@ spec:
1,
1001
],
"dtype": "float64",
"dType": "float64",
}
],
"layers": [
{
"name": "conv"
}
]
"layers": {
"conv": 1
}
},
"training": {
"git": {
Expand Down
14 changes: 6 additions & 8 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ When it comes to the specific supporting for model, we define our own [config](h
"value": "0.928"
}
],
"hyperparameters": [
"hyperParameters": [
{
"name": "batch_size",
"value": "32"
Expand All @@ -304,7 +304,7 @@ When it comes to the specific supporting for model, we define our own [config](h
224,
3
],
"dtype": "float64",
"dType": "float64",
}
],
"outputs": [
Expand All @@ -314,14 +314,12 @@ When it comes to the specific supporting for model, we define our own [config](h
1,
1001
],
"dtype": "float64",
"dType": "float64",
}
],
"layers": [
{
"name": "conv"
}
]
"layers": {
"conv": 1
}
},
"training": {
"git": {
Expand Down
22 changes: 10 additions & 12 deletions docs/spec-v1alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ Tensors are multi-dimensional arrays with a uniform type.

Description of the tensor.

- **dtype** string, OPTIONAL
- **dType** string, OPTIONAL

DType of the tensor.

- **size** object, OPTIONAL

Size of the tensor.

- **optype** string, OPTIONAL
- **opType** string, OPTIONAL

OpType of the tensor, It is only used for PMML.

Expand Down Expand Up @@ -113,9 +113,9 @@ Note: Any OPTIONAL field MAY also be set to null, which is equivalent to being a

Value of the metric

- **hyperparameters** object, OPTIONAL
- **hyperParameters** object, OPTIONAL

Hyperparameters of the model
HyperParameters of the model

- **name** string, REQUIRED

Expand Down Expand Up @@ -179,7 +179,7 @@ Here is an example model configuration JSON document:
"value": "0.9"
}
],
"hyperparameters": [
"hyperParameters": [
{
"name": "batch_size",
"value": "32"
Expand All @@ -194,7 +194,7 @@ Here is an example model configuration JSON document:
224,
3
],
"dtype": "float64",
"dType": "float64",
}
],
"outputs": [
Expand All @@ -204,14 +204,12 @@ Here is an example model configuration JSON document:
1,
1000
],
"dtype": "float64",
"dType": "float64",
}
],
"layers": [
{
"name": "conv"
}
]
"layers": {
"conv" : 1
}
},
"training": {
"git": {
Expand Down
4 changes: 2 additions & 2 deletions examples/Caffe2-model/ormbfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ signature:
- 3
- 224
- 224
dtype: float32
dType: float32
outputs:
- name: softmax
size:
- 1
- 1000
dtype: float32
dType: float32
4 changes: 2 additions & 2 deletions examples/GraphDef-model/ormbfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ framework: TensorFlow
signature:
inputs:
- name: input_1
dtype: float32
dType: float32
size:
- -1
- 224
- 224
- 3
outputs:
- name: Logits/Softmax
dtype: float32
dType: float32
size:
- -1
- 1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author: "chenjun <[email protected]>"
format: MXNETParams
format: MXNetParams
signature:
inputs:
- name: data
Expand All @@ -8,5 +8,5 @@ signature:
- 3
- 224
- 224
dtype: float32
dType: float32

4 changes: 2 additions & 2 deletions examples/TorchScript-model/ormbfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ signature:
- 3
- 224
- 224
dtype: float32
dType: float32
outputs:
- name: input__9
size:
- 1
- 1000
dtype: float32
dType: float32
8 changes: 4 additions & 4 deletions pkg/model/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
FormatPMML Format = "PMML"
FormatCaffeModel Format = "CaffeModel"
FormatNetDef Format = "NetDef"
FormatMXNETParams Format = "MXNETParams"
FormatMXNetParams Format = "MXNetParams"
FormatTorchScript Format = "TorchScript"
FormatGraphDef Format = "GraphDef"
FormatTensorRT Format = "TensorRT"
Expand Down Expand Up @@ -53,8 +53,8 @@ func (f Format) ValidateDirectory(rootPath string) error {
err = f.validateForCaffeModel(modelFilePath, fileList)
case FormatNetDef:
err = f.validateForNetDef(modelFilePath, fileList)
case FormatMXNETParams:
err = f.validateForMXNETParams(modelFilePath, fileList)
case FormatMXNetParams:
err = f.validateForMXNetParams(modelFilePath, fileList)
case FormatTorchScript:
err = f.validateForTorchScript(modelFilePath, fileList)
case FormatGraphDef:
Expand Down Expand Up @@ -182,7 +182,7 @@ func (f Format) validateForNetDef(modelPath string, files []os.FileInfo) error {
return nil
}

func (f Format) validateForMXNETParams(modelPath string, files []os.FileInfo) error {
func (f Format) validateForMXNetParams(modelPath string, files []os.FileInfo) error {
var jsonFileNum int32
var paramsFileNum int32
for _, file := range files {
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ var _ = Describe("Format", func() {
Expect(err).To(BeNil())
})

It("Should validate MXNETParams format successfully", func() {
savedmodelFormat := model.FormatMXNETParams
err := savedmodelFormat.ValidateDirectory("../../examples/MXNETParams-model")
It("Should validate MXNetParams format successfully", func() {
savedmodelFormat := model.FormatMXNetParams
err := savedmodelFormat.ValidateDirectory("../../examples/MXNetParams-model")
Expect(err).To(BeNil())
})

Expand Down
14 changes: 5 additions & 9 deletions pkg/model/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Metadata struct {
GPUType string `json:"gpuType,omitempty" yaml:"gpuType,omitempty"`
Framework string `json:"framework,omitempty" yaml:"framework,omitempty"`
Metrics []Metric `json:"metrics,omitempty" yaml:"metrics,omitempty"`
Hyperparameters []Hyperparameter `json:"hyperparameters,omitempty" yaml:"hyperparameters,omitempty"`
HyperParameters []HyperParameter `json:"hyperParameters,omitempty" yaml:"hyperParameters,omitempty"`
Signature *Signature `json:"signature,omitempty" yaml:"signature,omitempty"`
Training *Training `json:"training,omitempty" yaml:"training,omitempty"`
Dataset *Dataset `json:"dataset,omitempty" yaml:"dataset,omitempty"`
Expand All @@ -37,31 +37,27 @@ type Metric struct {
}

// Hyperparameter is the type for training hyperparameter (e.g. learning rate).
type Hyperparameter struct {
type HyperParameter struct {
Name string `json:"name"`
Value string `json:"value"`
}

type Signature struct {
Inputs []Tensor `json:"inputs,omitempty" yaml:"inputs,omitempty"`
Outputs []Tensor `json:"outputs,omitempty" yaml:"outputs,omitempty"`
Layers []Layer `json:"layers,omitempty" yaml:"layers,omitempty"`
Layers map[string]int `json:"layers,omitempty" yaml:"layers,omitempty"`
}

type Tensor struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Size []int `json:"size,omitempty" yaml:"size,omitempty"`
DType string `json:"dtype,omitempty" yaml:"dtype,omitempty"`
DType string `json:"dType,omitempty" yaml:"dType,omitempty"`
// OpType is special for PMML
OpType string `json:"optype,omitempty" yaml:"optype,omitempty"`
OpType string `json:"opType,omitempty" yaml:"opType,omitempty"`
// Values is special for PMML
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
}

type Layer struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
}

type Training struct {
Git GitRepo `json:"git,omitempty" yaml:"git,omitempty"`
}
Expand Down