如何解决如何用其他代码导入CNN模型?
这是我的“模型”,出于理解目的,我在此处添加了一部分。我希望将此模型导入另一段名为“ trainer”的代码中。
import torch.nn as nn
import torch
class Signet(nn.Module):
def __init__(self,num_users=10):
super(Signet,self).__init__()
self.num_classes = num_users
self.forward_util_layer = {}
import model
class Trainer:
def __init__(self,trainData,testData,num_users=10):
self.trainData = trainData
self.testData = testData
导入它的方式是什么。在哪里保存我的model.ipynb,以便我的trainer.ipynb可以导入它。还是有什么办法可以直接在我的trainer.ipynb代码中调用它?
解决方法
将模型代码移动到<xsl:template name="priceSumSegmented">
<xsl:param name="productList"/>
<xsl:param name="segmentLength" select="5"/>
<xsl:choose>
<xsl:when test="count($productList) > 0">
<xsl:variable name="recursive_result1">
<xsl:call-template name="priceSum">
<xsl:with-param name="productList"
select="$productList[position() <= $segmentLength]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="recursive_result2">
<xsl:call-template name="priceSumSegmented">
<xsl:with-param name="productList"
select="$productList[position() > $segmentLength]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$recursive_result1 + $recursive_result2"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
文件中。将该文件与model.py
现在,要将模型加载到ipynb文件中,请按照下列步骤操作。
trainer.ipynb
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。