I made neural net and tried to cord which predict labels.
So I load model ,which finished learning, to the cord for estimating labels.
But, the error occurred about definition of variables which are defined in model.
Did I mistake to load model for neural net?
The error message
Traceback (most recent call last):
  File "C:/Users/name/Desktop/myo-python-1.0.4/bindsnet-master/bindsnet/predicted_RSNN.py", line 154, in <module>
    pred = torch.mean(predicted, feed_dict={x: np.array([tmp])})
NameError: name 'predicted' is not defined

Model of neural net
class LogisticRegression(nn.Module):
    def __init__(self, input_size, num_classes):
        super(LogisticRegression, self).__init__()
        self.linear = nn.Linear(input_size, num_classes)
    def forward(self, x):
        out = self.linear(x)
        predicted = torch.max(out.softmax(0), 1)
        #out = torch.sigmoid(self.linear(x.float().view(-1)))
        return out, predicted, x

cord
from collections import deque
from threading import Lock
import myo
import time
import numpy as np
from time import sleep
import torch
import torch.nn as nn
model_path = "C:/Users/name/Desktop/myo-python-1.0.4/bindsnet-master/bindsnet/pytorchsession/snn.pth"

class MyListener(myo.DeviceListener):
    def __init__(self, queue_size=8):
        self.lock = Lock()
        self.emg_data_queue = deque(maxlen=queue_size)
        self.orientation_data_queue = deque(maxlen=queue_size)
        self.acceleration_data_queue = deque(maxlen=queue_size)
        self.gyroscope_data_queue = deque(maxlen=queue_size)
        self.rssi_data_queue = deque(maxlen=100)
        self.pose = myo.Pose.rest
        self.connected = False
        self.battery_level = 100
        self.emg_enabled = False
        self.locked = False
        self.rssi = None
        self.emg = None
        self.device_name = None
        self.device = None
        self.myo_firmware = None
        self.arm = None
        self.x_direction = None
        self.sync = None

    def on_paired(self, event):
        if __name__ == '__main__':
            print('paired')
        else:
            pass

    def on_unpaired(self, event):
        if __name__ == '__main__':
            print('unpaired')
        else:
            pass

    def on_connected(self, event):
        self.device = event.device
        event.device.unlock()
        event.device.lock()
        event.device.stream_emg(True)
        self.connected = True
        self.device_name = event.device_name
        self.myo_firmware = '.'.join(map(str, event.firmware_version[:-1]))

    def on_disconnected(self, event):
        self.connected = False

    def on_arm_synced(self, event):
        self.sync = True
        self.arm = event.arm
        self.x_direction = event.x_direction
        if __name__ == '__main__':
            print(self.x_direction)
        else:
            pass

    def on_arm_unsynced(self, event):
        self.sync = False
        if __name__ == '__main__':
            print(f'arm unsynced : {event.arm}')
        else:
            pass

    def on_unlocked(self, event):
        self.locked = False

    def on_locked(self, event):
        self.locked = True

    def on_pose(self, event):
        self.pose = event.pose

    def on_orientation(self, event):
        with self.lock:
            self.orientation_data_queue.append((event.timestamp,
                                                event.orientation))
            self.gyroscope_data_queue.append((event.timestamp,
                                              event.gyroscope))
            self.acceleration_data_queue.append((event.timestamp,
                                                 event.acceleration))

    def on_rssi(self, event):
        with self.lock:
            self.rssi_data_queue.append(-event.rssi)

    def on_battery_level(self, event):
        self.battery_level = event.battery_level

    def on_emg(self, event):
        with self.lock:
            self.emg_data_queue.append((event.timestamp,
                                        event.emg))

    def on_warmup_completed(self, event):
        event.device.stream_emg(True)
        self.emg_enabled = True

    def get_emg_data(self):
        with self.lock:
            return list(self.emg_data_queue)

    def get_orientation_data(self):
        with self.lock:
            return list(self.orientation_data_queue)

    def get_gyroscope_data(self):
        with self.lock:
            return list(self.gyroscope_data_queue)

    def get_accelerometor_data(self):
        with self.lock:
            return list(self.acceleration_data_queue)
if __name__ == '__main__':

    myo.init(bin_path=r'C:\Users\name\Desktop\myo-sdk-win-0.9.0\bin')
    HUB = myo.Hub()
    listener = MyListener()
    start = time.time()
    temp = []
    with HUB.run_in_background(listener.on_event):
        while True:
            data = listener.get_emg_data()
            if time.time() - start >= 1:
                response = np.argmax(np.bincount(temp))
                print("Predicted gesture: {0}".format(response))
                temp = []
                start = time.time()
            if len(data) > 0:
                tmp = []
                for v in listener.get_emg_data():
                    tmp.append(v[1])
                tmp = list(np.stack(tmp).flatten())
                if len(tmp) >= 64:
                    pred = torch.mean(predicted, feed_dict={x: np.array([tmp])}) ☚ error
                    pred = sess.run(y_pred_cls, feed_dict={x: np.array([tmp])})
                    temp.append(pred[0])
            sleep(0.01)