예제 #1
0
 def reset(self):
     if self._filename is None:
         self.delay_queue = DelayQueue(0.01)
     else:
         self.delay_queue = NoloopDelayQueue(self._filename, 0.01)
     self.random_video()
     self.state = np.zeros((S_INFO, S_LEN))
     return self.state
예제 #2
0
 def __init__(self, random_seed=RANDOM_SEED, filename=None):
     np.random.seed(random_seed)
     self._filename = filename
     if self._filename is None:
         self.delay_queue = DelayQueue(0.01)
     else:
         self.delay_queue = NoloopDelayQueue(self._filename, 0.01)
     self.simtime = 0.0
     self._video = None
     self._videocount = 0.0
     self._videoindex = 0.0
     self._video_vmaf = []
     self._video_len = []
     self.random_video()
예제 #3
0
    def __init__(self, random_seed=0, filename=None):
        #os.system('rm -rf results')
        os.system('mkdir results')
        np.random.seed(int(time.time()))
        _id = np.random.randint(1000)
        self._filename = filename
        if self._filename is None:
            self.delay_queue = DelayQueue(0.01)
        else:
            self.delay_queue = NoloopDelayQueue(self._filename, 0.01)
        self.simtime = 0.0
        self._video = None
        self._videocount = 0.0
        self._videoindex = 0.0
        self._video_vmaf = []
        self._video_len = []
        self.random_video()
        self.last_rtt = -1
        self.last_vmaf = -1
        self.time_stamp = 0.0
        self.state = np.zeros((S_INFO, S_LEN))

        self.x = tf.placeholder(
            shape=[None, INPUT_SEQ, INPUT_H, INPUT_W, INPUT_D],
            dtype=tf.float32)
        self.y_ = tf.placeholder(shape=[None, OUTPUT_DIM], dtype=tf.float32)
        self.core_net = self.vqn_model(self.x)

        self.core_net_loss = tflearn.objectives.mean_square(
            self.core_net, self.y_)

        gpu_options = tf.GPUOptions(allow_growth=True)
        self.sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
        self.sess.run(tf.global_variables_initializer())
        self.saver = tf.train.Saver()
        self.saver.restore(self.sess, "model/nn_model_ep_best.ckpt")
        self.x_buff = np.zeros([INPUT_SEQ, INPUT_H, INPUT_W, INPUT_D])

        self.action_space = spaces.Discrete(A_DIM)
        self.observation_space = spaces.Box(0,
                                            5.0, [S_INFO, S_LEN],
                                            dtype=np.float32)

        self.last_vmaf_fake = -1
        _strtime = time.strftime('%b-%d-%H:%M:%S-%Y', time.localtime())
        self.log_file = open(LOG_FILE + '_' + str(_strtime), 'wb')
예제 #4
0
    def __init__(self, random_seed=RANDOM_SEED, filename=None):
        np.random.seed(random_seed)
        self._filename = filename
        if self._filename is None:
            self.delay_queue = DelayQueue(0.01)
        else:
            self.delay_queue = NoloopDelayQueue(self._filename, 0.01)
        self.simtime = 0.0
        self._video = None
        self._videocount = 0.0
        self._videoindex = 0.0
        self._video_vmaf = []
        self._video_len = []
        self.random_video()

        self.x = tf.placeholder(
            shape=[None, INPUT_SEQ, INPUT_H, INPUT_W, INPUT_D],
            dtype=tf.float32)
        self.y_ = tf.placeholder(shape=[None, OUTPUT_DIM], dtype=tf.float32)
        self.core_net = self.vqn_model(self.x)

        self.core_net_loss = tflearn.objectives.mean_square(
            self.core_net, self.y_)
        # + lossL2
        # self.core_train_op = tf.train.AdamOptimizer(
        #    learning_rate=LR_RATE).minimize(self.core_net_loss)
        # self.core_net_acc = tf.reduce_mean(
        #    tf.abs(core_net - y_) / (tf.abs(core_net) + tf.abs(y_) / 2))
        # core_net_mape = tf.subtract(1.0, tf.reduce_mean(
        #    tf.abs(core_net - y_) / tf.abs(y_)))
        #train_len = X.shape[0]

        #g2 = tf.Graph()
        #gpu_options = tf.GPUOptions(allow_growth=True)
        self.sess = tf.Session()
        self.sess.run(tf.global_variables_initializer())
        self.saver = tf.train.Saver()
        self.saver.restore(self.sess, "model/nn_model_ep_350.ckpt")
        self.x_buff = np.zeros([INPUT_SEQ, INPUT_H, INPUT_W, INPUT_D])