Как использовать внедрение зависимостей в универсальном репозитории и UnitOfWork

Вы можете сделать это с помощью numpy.eye и использовать механизм выбора элемента массива:

import numpy as np
nb_classes = 6
data = [[2, 3, 4, 0]]

def indices_to_one_hot(data, nb_classes):
    """Convert an iterable of indices to one-hot encoded labels."""
    targets = np.array(data).reshape(-1)
    return np.eye(nb_classes)[targets]

Возвращаемое значение indices_to_one_hot(nb_classes, data) теперь

array([[[ 0.,  0.,  1.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  1.,  0.,  0.],
        [ 0.,  0.,  0.,  0.,  1.,  0.],
        [ 1.,  0.,  0.,  0.,  0.,  0.]]])

.reshape(-1), чтобы убедиться, что у вас есть правильный формат ярлыков (у вас также может быть [[2], [3], [4], [0]]).

0
задан Morteza 16 January 2019 в 05:22
поделиться

1 ответ

добавить новый проект в решение с именем «Configure»
добавить castle.windsor из NuGet ко всему проекту
добавить класс к этому проекту с именем «Bootstrapper» и написать этот код

public static WindsorContainer Container = null;

   public static void WireUp()
   {
                    Container = new WindsorContainer();
                    Container.Register(Component.For<GlobalERPEntities>());
                    Container.Register(Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>());
                    Container.Register(Component.For<IService_HR_Person>().ImplementedBy<Service_HR_Person>());
   }

и отредактируйте свой код в пользовательском интерфейсе

 using (Service_HR_Person srvPerson = Bootstrapper.Container.Resolve<Service_HR_Person>())
                {
                    srvPerson.Delete(base.rowid);
                    try
                    {
                        srvPerson.Save();
                        RemoveRow();
                        MessageManager.Show(Enums.MessageBoxType.InformationTransactionSuccessfully);
                    }
                    catch (Exception ex)
                    {
                        MessageManager.Show(ErrorManager.ProccessException(ex), Enums.MessageBoxType.Error);
                    }
                }

в этой строке

 using (Service_HR_Person srvPerson = Bootstrapper.Container.Resolve<Service_HR_Person>())

и отредактируйте Program.cs с этим кодом [ 1110]

 static void Main(string[] argss)
        {
            Bootstrapper.WireUp();

это работа в основном

0
ответ дан xxxsenatorxxx 16 January 2019 в 05:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: