如何从张量中提取转换层输出

时间:2018-06-11 12:46:32

标签: python tensorflow

我正在使用private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e) { SerialPort port = (SerialPort)sender; int index = m_ports.FindIndex(p => p.PortName == port.PortName); string tmpData; m_currentData[index] += tmpData = port.ReadExisting(); Console.WriteLine(tmpData); string currentData = m_currentData[index]; string currentOrder = ""; while (currentData.Contains(orderEndChar)) { int endCharLocation = currentData.IndexOf(orderEndChar); currentOrder = currentData.Substring(0, endCharLocation); currentData = currentData.Substring(endCharLocation + 1); orderEvent.gotOrder(currentOrder); //orderEvent.gotOrder(new EventArgs()); } m_currentData[index] = currentData; } 构建CNN模型。我想从第一个卷积层conv1中的张量中提取矩阵。

我只能得到它的形状:
tensorflow

我想提取输出张量的(4,5)矩阵。 我怎么能用Python做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以通过运行来获取张量的输出:

tensor_name.eval(feed_dict={...})

并在第一次定义时将tensor_name替换为您调用张量的任何内容。

除非您正在寻找此图层的权重?在这种情况下,我认为这应该回答您的问题:Get the value of some weights in a model trained by TensorFlow

相关问题