我已经在Tensorflow中将模型训练为Color_Model,并且效果很好。我想使用这个训练有素的模型来训练另一个模型作为Motion_Model。实际上,Color_Model的输出进入Motion_Model有助于训练Motion_Model。但是问题是我不知道如何加载Color_Model图和设置Motion_Model图,以便Tensorflow知道它们是分开的。我在Motion_Model中更改了权重的名称,因此它们没有任何名称冲突。
这是加载和训练代码的一部分:
String user=new String(tf1.getText());
String pass=new String(pf1.getPassword());
String mb=new String(tf2.getText());
String email=new String(tf3.getText());
String query="INSERT into user_info (username,password,email_id,mobile number) VALUES('"+user+"','"+pass+"','"+email+"','"+mb+"')";
try {
Connection myConn=DriverManager.getConnection("jdbc:mysql://localhost:3306/javaproject","root","noor1032");
System.out.println("databse connected");
PreparedStatement myStat=myConn.prepareStatement(query);
System.out.println("statement prepapred");
myStat.setString(1, user);
myStat.setString(2, pass);
myStat.setString(3, email);
myStat.setString(4, mb);
myStat.executeUpdate();
System.out.println("query executed");
myConn.close();
JOptionPane.showMessageDialog(null, "saved");
}
catch(Exception f)
{
System.err.println("Got an exception!");
System.err.println(f.getMessage());
}
如您所见,第一个“ sess.run”运行Color_Model以从中获取输出,第二个“ sess.run”获取此输出并将其馈送到Motion_Model进行训练。
但是当我运行这段代码时,出现以下错误:
with tf.Session() as sess:
sess.run(init_op)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
###Loaing the color model
new_saver = tf.train.import_meta_graph('./Color_Model/Deep_CNN_Color_Arch16.ckpt-44.meta')
new_saver.restore(sess,tf.train.latest_checkpoint('./Color_Model/'))
graph = tf.get_default_graph()
X = graph.get_tensor_by_name("X:0")
Y = graph.get_tensor_by_name("Y:0")
phase = graph.get_tensor_by_name("phase:0")
A7 = graph.get_tensor_by_name("Finalo:0")
##########################
###Training phase
for step in range(1, iterations+1):
###Getting the training data batch
img = sess.run([image])
X_temp = img[0][:,:,:,0:8]
Y_temp = img[0][:,:,:,8:9]
X_temp = X_temp.astype(np.float32)/255
Y_temp = Y_temp.astype(np.float32)/255
###Getting the color model result
output = sess.run([A7], feed_dict = {X: X_temp[:,:,:,5:8], Y: Y_temp, phase: False})
###Training the motion model
_, c, outputM = sess.run([optimizer, costM, MN_out], feed_dict = {XM: X_temp[:,:,:,0:5], YM: Y_temp, phaseM: True, ZM: output})
我非常确定这是在混合图形,因为WM1是Motion_Model中第一层的权重,实际上错误是说它无法在引用我猜为Color_Model的检查点中找到它。 如果您能帮助我解决这个问题,我非常感谢。