Тип инициализатор для 'tensorflow.finding' бросил исключениеC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Тип инициализатор для 'tensorflow.finding' бросил исключение

Сообщение Anonymous »

Я хотел использовать tensorflow.net (v0.150.0 от Haiping Cheng) с C# 4.7.2 и Visual Studio 2017 (потому что мой компьютер старый, и я не понимаю, почему я должен обновить свой компьютер с каждым выпуском. Net). < /P>
Следующие были моими исходными и тестовыми кодами: < /p>

Код: Выделить всё

using System;
using System.Linq;
using Tensorflow;
using static Tensorflow.Binding;

namespace SimulationLib
{
public class TfMatrix : IEquatable
{
private Tensor _matrix;

public TfMatrix(float[,] values)
{
if (values == null || values.GetLength(0) == 0 || values.GetLength(1) == 0)
throw new ArgumentException("Values array must not be null or empty.");

_matrix = tf.constant(values);
}

public TfMatrix(int rows, int cols)
{
if (rows  (int)_matrix.shape[1];
}
}

Код: Выделить всё

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow;
using static Tensorflow.Binding;

namespace SimulationLib.Tests
{
[TestClass]
public class TfMatrixTests
{
[TestMethod]
public void TestConstructorWith2DArray()
{
float[,] values = new float[,] { { 1, 2 }, { 3, 4 } };
TfMatrix matrix = new TfMatrix(values);

Assert.AreEqual(2, matrix.Rows);
Assert.AreEqual(2, matrix.Columns);
Assert.AreEqual(1, matrix[0, 0]);
Assert.AreEqual(4, matrix[1, 1]);
}
}
}
Проблема в том, что ошибка говорит следующее:

Код: Выделить всё

Test Name:  TestConstructorWith2DArray
Test FullName:  SimulationLib.Tests.TfMatrixTests.TestConstructorWith2DArray
Test Source:    C:\git\Simulation\Simulation\unit_test_3d_for_TfMatrix\UnitTest1.cs : line 12
Test Outcome:   Failed
Test Duration:  0:00:01.2855111

Result StackTrace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Tensorflow.ops.RegisterFromAssembly()
at Tensorflow.tensorflow.InitGradientEnvironment()
at Tensorflow.tensorflow..ctor()
at Tensorflow.Binding..cctor()
--- End of inner exception stack trace ---
at Tensorflow.Binding.get_tf()
at SimulationLib.TfMatrix..ctor(Single[,] values) in C:\git\Simulation\Simulation\PolymerSimLib\Primitives\TfMatrix.cs:line 17
at SimulationLib.Tests.TfMatrixTests.TestConstructorWith2DArray() in C:\git\Simulation\Simulation\unit_test_3d_for_TfMatrix\UnitTest1.cs:line 15
Result Message:
Test method SimulationLib.Tests.TfMatrixTests.TestConstructorWith2DArray threw exception:
System.TypeInitializationException: The type initializer for 'Tensorflow.Binding' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.  Retrieve the LoaderExceptions property for more information.

Как я могу решить эту проблему?

Подробнее здесь: https://stackoverflow.com/questions/793 ... -exception
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»