示例#1
0
import numpy as np
import os
import json
import matplotlib.pyplot as plt

if __name__ == '__main__':

    nepisodes = 500
    lambda_param = 1
    return_type = 'Retrace'

    datadir = 'data'
    if not os.path.exists(datadir):
        os.mkdir(datadir)
        print('collecting data ...')
        collect_dataset(datadir)
        print('estimating true Q function ...')
        with open(os.path.join(datadir, 'test_points.json'), 'r') as f:
            test_points = json.load(f)
        estimate_true_q(test_points, datadir, nepisodes=100)

    with open(os.path.join(datadir, 'test_points.json'), 'r') as f:
        test_points = json.load(f)
    data = np.load(os.path.join(datadir, 'dataset_0.npy'))
    true_q = np.load(os.path.join(datadir, 'true_q.npy'))
    value_function = ValueFunction()

    print('estimating key quantities ...')
    test_data = np.load(os.path.join(datadir, 'dataset_0.npy'))
    A, b, M_inv = estimate_key_quantities(value_function, test_data,
                                          lambda_param, return_type)
示例#2
0
import cv2
from WebcamCapture import WebcamCapture
from FaceDetection import FaceDetection
from ProcessImage import ProcessImage
from utils import collect_dataset

images, labels, label_dic = collect_dataset()
rec_lbph = cv2.face.LBPHFaceRecognizer_create()
rec_lbph.train(images, labels)

camera = WebcamCapture()
face_detector = FaceDetection()
image_processor = ProcessImage()

images, labels, label_dic = collect_dataset()

rec_lbph = cv2.face.LBPHFaceRecognizer_create()
rec_lbph.train(images, labels)

rec_eigen = cv2.face.EigenFaceRecognizer_create()
rec_eigen.train(images, labels)

rec_fisher = cv2.face.FisherFaceRecognizer_create()
rec_fisher.train(images, labels)

collector = cv2.face.StandardCollector_create()

frame = camera.get_feed()
faces_area = face_detector.detect_face(frame)

if len(faces_area):
示例#3
0
                                    self.models[i][0]) + self.models[i][1]
            prediction_result[inds] = np.argmax(predict_values, axis=1)
        #print (prediction_result.shape)
        #print (prediction_result)
        return prediction_result


if __name__ == "__main__":
    from actor_wrapper import Actor_LIME
    from utils import collect_dataset
    from sklearn.model_selection import train_test_split

    actor = Actor_LIME(
        nn_model="../pensieve_test/models/pretrain_linear_reward.ckpt")

    dataset = collect_dataset().values
    labels = np.argmax(actor.predict(dataset), axis=1)

    X_train, X_test, y_train, y_test = train_test_split(dataset,
                                                        labels,
                                                        test_size=0.2)

    print(X_train.shape, X_test.shape, y_train.shape, y_test.shape)

    with open("./lime_extended_performance.csv", "w") as FILE:
        for j in range(100):
            X_train, X_test, y_train, y_test = train_test_split(dataset,
                                                                labels,
                                                                test_size=0.2)
            for i in range(1, 50):
                lime_model = LIMESimpleModel(cluster_num=i)