小编Ani*_*rma的帖子

'Net' 对象没有属性 'parameters'

我对机器学习相当陌生。我学会了从 youtube 教程中编写此代码,但我不断收到此错误

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/aniket/Desktop/DeepLearning/PythonLearningPyCharm/CatVsDogs.py", line 109, in <module>
    optimizer = optim.Adam(net.parameters(), lr=0.001) # tweaks the weights from what I understand
AttributeError: 'Net' object has no attribute 'parameters'
Run Code Online (Sandbox Code Playgroud)

这是网络课

class Net():
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1,32,5)
        self.conv2 = nn.Conv2d(32,64,5)
        self.conv3 = nn.Conv2d(64,128,5)
        self.to_linear = …
Run Code Online (Sandbox Code Playgroud)

neural-network deep-learning conv-neural-network pytorch

1
推荐指数
1
解决办法
3371
查看次数

if 语句未在 c# unity 中执行

我试图让一个角色移动一定距离,然后在他们移动一定距离时改变方向......我的代码中的逻辑可能是错误的我仍然需要解决这不是问题,问题是我的 if 语句不执行

public class EnemyControl : MonoBehaviour
{
    private int xMoveDirection=-1;
    private float x;
    void Start()
    {
        x=gameObject.transform.position.x;
    }
    void Update()
    {
        gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(xMoveDirection,0);
        if(x==0.00){
          Debug.Log("helloimhere");
          xMoveDirection=0;
          x=x+1;
        }
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine game-physics

-2
推荐指数
1
解决办法
50
查看次数