在我的代码中,我遇到了SyntaxError:分配变量时语法无效。该变量的分配方式与之前的一样,因此我无法确定出了什么问题。
import numpy as np
from tensorflow import nn
from nn import sigmoid
class NeuralNet:
def __init__(self, inputs, output):
self.input = inputs
assert inputs <= 0, print("test")
self.weights1 = np.random.rand(self.input.shape[1],units1 = 4)
self.weights2 = np.random.rand(units1 ,units2 = 4)
self.weights3 = np.random.rand(units2 ,units3 = 4)
self.weights4 = np.random.rand(units3 ,final = 1)
# self.output = output
self.output = np.zeros(self.output.shape)
self.score = None
def feedForward(self):
self.layer1 = sigmoid(np.dot(self.input , self.weights1)
self.layer2 = sigmoid(np.dot(self.weights1, self.weights2) #line 23
self.layer3 = sigmoid(np.dot(self.weights2, self.weights3)
self.output = sigmoid(np.dot(self.weights3, self.weights4)
NNet = NeuralNet(0,0)
我希望它能正常工作并输出“ test”,但该程序在第23行因无效的语法错误而中断。 我在做什么错了?