C# tf.train.Saver()不适用于Tensorflow.net
上面的简单代码在下一行导致异常。原因是什么? 请使用NuGet Manager获取C# tf.train.Saver()不适用于Tensorflow.net,c#,tensorflow,machine-learning,.net-core,C#,Tensorflow,Machine Learning,.net Core,上面的简单代码在下一行导致异常。原因是什么? 请使用NuGet Manager获取 TensorFlow.NET SciSharp.TensorFlow.Redist 测试前的包装 using System; using Tensorflow; using static Tensorflow.Binding; namespace ConsoleApp1 { class Program { static void Main(string[] args)
using System;
using Tensorflow;
using static Tensorflow.Binding;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var w1 = tf.Variable(0, name: "save1");
var init_op = tf.global_variables_initializer();
// Add ops to save and restore all the variables.
var saver = tf.train.Saver(new IVariableV1[]{w1 });
using (var sess = tf.Session())
{
sess.run(init_op);
// Save the variables to disk.
var save_path = saver.save(sess, "/tmp/model1.ckpt");
Console.WriteLine($"Model saved in path: {save_path}");
}
Console.ReadKey();
}
}
}
@磁控管虽然标签的更正是赞赏的,但一定要解决所有问题的帖子时,编辑他们。
var saver = tf.train.Saver(new IVariableV1[]{w1 });
System.NullReferenceException: 'Object reference not set to an instance of an object.'