forked from huawei/mindspore2022
!19204 Fix errors due to the mindspore_hub_conf file
Merge pull request !19204 from dinglinhe/dlh_code_ms_I3J8EP_2
This commit is contained in:
commit
4b5ed4b826
|
|
@ -14,12 +14,17 @@
|
|||
# ============================================================================
|
||||
"""hub config"""
|
||||
from src.cnn_ctc import CNNCTC_Model
|
||||
from src.config import Config_CNNCTC
|
||||
|
||||
def cnnctc(*args, **kwargs):
|
||||
def cnnctc_net(*args, **kwargs):
|
||||
return CNNCTC_Model(*args, **kwargs)
|
||||
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
"""
|
||||
create cnnctc network
|
||||
"""
|
||||
if name == "cnnctc":
|
||||
return CNNCTC_Model(*args, **kwargs)
|
||||
config = Config_CNNCTC
|
||||
return cnnctc_net(config.NUM_CLASS, config.HIDDEN_SIZE, config.FINAL_FEATURE_WIDTH, *args, **kwargs)
|
||||
raise NotImplementedError(f"{name} is not implemented in the repo")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ def efficinetnet(*args, **kwargs):
|
|||
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
if name == "efficinetnet":
|
||||
if name == "efficientnet":
|
||||
return efficientnet_b0(*args, **kwargs)
|
||||
raise NotImplementedError(f"{name} is not implemented in the repo")
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@
|
|||
from src.mobilenetV2 import MobileNetV2Backbone, MobileNetV2Head, mobilenet_v2
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
"""create_network about mobilenetv2"""
|
||||
"""
|
||||
create mobilenetv2 network
|
||||
"""
|
||||
if name == "mobilenetv2":
|
||||
backbone_net = MobileNetV2Backbone()
|
||||
include_top = kwargs.get("include_top", True)
|
||||
if include_top is None:
|
||||
include_top = True
|
||||
num_class = kwargs.get("num_classes", "10")
|
||||
if include_top:
|
||||
activation = kwargs.get("activation", True)
|
||||
head_net = MobileNetV2Head(input_channel=backbone_net.out_channels,
|
||||
num_classes=int(kwargs["num_classes"]),
|
||||
num_classes=int(num_class),
|
||||
activation=activation)
|
||||
net = mobilenet_v2(backbone_net, head_net)
|
||||
return net
|
||||
|
|
|
|||
|
|
@ -14,12 +14,24 @@
|
|||
# ============================================================================
|
||||
"""hub config"""
|
||||
from src.squeezenet import SqueezeNet
|
||||
from src.config import config1, config2, config3, config4
|
||||
|
||||
def squeezenet(*args, **kwargs):
|
||||
def squeezenet_net(*args, **kwargs):
|
||||
return SqueezeNet(*args, **kwargs)
|
||||
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
dataset = kwargs.get("dataset", "cifar10")
|
||||
if name == "squeezenet":
|
||||
return SqueezeNet(*args, **kwargs)
|
||||
if dataset == "cifar10":
|
||||
config = config1
|
||||
else:
|
||||
config = config2
|
||||
return squeezenet_net(num_classes=config.class_num)
|
||||
if name == "squeezenet_residual":
|
||||
if dataset == "cifar10":
|
||||
config = config3
|
||||
else:
|
||||
config = config4
|
||||
return squeezenet_net(num_classes=config.class_num)
|
||||
raise NotImplementedError(f"{name} is not implemented in the repo")
|
||||
|
|
|
|||
|
|
@ -14,12 +14,26 @@
|
|||
# ============================================================================
|
||||
"""hub config."""
|
||||
from src.bgcf import BGCF
|
||||
from src.config import parser_args
|
||||
|
||||
def bgcf(*args, **kwargs):
|
||||
def bgcf_net(*args, **kwargs):
|
||||
return BGCF(*args, **kwargs)
|
||||
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
"""
|
||||
create bgcf network
|
||||
"""
|
||||
if name == "bgcf":
|
||||
return bgcf(*args, **kwargs)
|
||||
config = parser_args()
|
||||
config.num_user = 7068
|
||||
config.num_item = 3570
|
||||
return bgcf_net([config.input_dim, config.num_user, config.num_item],
|
||||
config.embedded_dimension,
|
||||
config.activation,
|
||||
[0.0, 0.0, 0.0],
|
||||
config.num_user,
|
||||
config.num_item,
|
||||
config.input_dim,
|
||||
*args, **kwargs)
|
||||
raise NotImplementedError(f"{name} is not implemented in the repo")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""hub config."""
|
||||
import gym
|
||||
from src.agent import Agent
|
||||
from src.config import config_dqn as cfg
|
||||
|
||||
def dqn_net(*args, **kwargs):
|
||||
agent = Agent(*args, **kwargs)
|
||||
return agent.policy_net
|
||||
|
||||
|
||||
def create_network(name, *args, **kwargs):
|
||||
"""
|
||||
create dqn network
|
||||
"""
|
||||
if name == "dqn":
|
||||
env = gym.make('CartPole-v1')
|
||||
cfg.state_space_dim = env.observation_space.shape[0]
|
||||
cfg.action_space_dim = env.action_space.n
|
||||
return dqn_net(**cfg)
|
||||
raise NotImplementedError(f"{name} is not implemented in the repo")
|
||||
Loading…
Reference in New Issue