Esempio n. 1
0
    AZURE_STORAGE_ACCOUNT_NAME = "check Account name"
    AZURE_STORAGE_ACCOUNT_KEY = "check Account key"
    AZURE_STORAGE_NAME = "check storage name"
    PAPAGO_API_ID = 'check papago api id'
    PAPAGO_API_SECRET = 'check papago api secret'

# model, config files download and unzip
try:
    FILE_SERVICE = FileService(account_name=AZURE_STORAGE_ACCOUNT_NAME,
                               account_key=AZURE_STORAGE_ACCOUNT_KEY)
    logging.debug("MODEL_ABS_PATH : %s", MODEL_ABS_PATH)
    if os.path.exists(MODEL_ABS_PATH):
        shutil.rmtree(MODEL_ABS_PATH)

    FILE_SERVICE.get_file_to_path(AZURE_STORAGE_NAME,
                                  constant.STORAGE_BERT_SENTIMENT_DIR,
                                  constant.MODEL_ZIP_NAME, MODEL_ZIP_ABS_PATH)
    FILE_SERVICE.get_file_to_path(AZURE_STORAGE_NAME,
                                  constant.STORAGE_BERT_SENTIMENT_DIR,
                                  constant.BERT_CONFIG_NAME,
                                  CONFIG_FILE_ABS_PATH)
    shutil.unpack_archive(MODEL_ZIP_ABS_PATH, extract_dir=DIRNAME)

except Exception as e:
    logging.critical("Unexpected error : %s", e)
    sys.exit()

# print(DIRNAME)

pretrained_model_path = os.path.join(MODEL_ABS_PATH, constant.MODEL_BIN_NAME)
# print(pretrained_model_path)
AZTenantId = "78820852-55fa-450b-908d-45c0d911e76b"

logging.info("Getting OCI config files from file share - account: %s " %
             storage_account)
file_service = FileService(
    account_name=storage_account,
    account_key=automationassets.get_automation_variable(
        'oci_storage_account_key'))

# Create target Directory if don't exist
if not os.path.exists('.oci'):
    os.mkdir('.oci')
    logging.info("Created the .oci directory")

logging.info("Downloading config files to .oci")
file_service.get_file_to_path(storage_share, '.oci', 'config', '.oci/config')
file_service.get_file_to_path(storage_share, '.oci', 'oci_api_key.pem',
                              '.oci/oci_api_key.pem')
file_service.get_file_to_path(storage_share, '.oci', 'oci_api_key_public.pem',
                              '.oci/oci_api_key_public.pem')

if not os.path.exists('.oci/config'):
    logging.error("File .oci/config missing!")
    exit(1)

if not os.path.exists('.oci/oci_api_key.pem'):
    logging.error("File .oci/oci_api_key.pem missing!")
    exit(1)

if not os.path.exists('.oci/oci_api_key_public.pem'):
    logging.error("File .oci/oci_api_key_public.pem missing!")
Esempio n. 3
0
SAVER = "saver"
SAVER_FOLDER = "./" + SAVER
TRAIN_DATA = "data-04-zoo.csv"
RESULT_FILE = 'result.json'
FILE_SHARE = 'tensorflow-savedata'

for file in os.listdir(SAVER_FOLDER):
    os.remove(SAVER_FOLDER + "/" + file)

file_service = FileService(
    account_name='tensotfolwsavedata',
    account_key=
    'Vm/Mwh6qm1J5w3bGPFDapWBmC2zl4At4yy5HQrand7bTSy3Q6lCJdZdCYmZ3phQ/rrCgChKR0qWsCOcclWpzxQ=='
)

file_service.get_file_to_path(FILE_SHARE, None, TRAIN_DATA, TRAIN_DATA)
file_service.create_directory(FILE_SHARE, SAVER)

xy = np.loadtxt(TRAIN_DATA, delimiter=',', dtype=np.float32)
x_data = xy[:, 0:-1]
y_data = xy[:, [-1]]
nb_classes = 7

X = tf.placeholder(tf.float32, [None, 16])
Y = tf.placeholder(tf.int32, [None, 1])

Y_one_hot = tf.one_hot(Y, nb_classes)
Y_one_hot = tf.reshape(Y_one_hot, [-1, nb_classes])

W = tf.Variable(tf.random_normal([16, nb_classes]), name='weight')
b = tf.Variable(tf.random_normal([nb_classes]), name='bias')