diff --git a/src/nn.py b/src/nn.py new file mode 100644 index 0000000..d58087f --- /dev/null +++ b/src/nn.py @@ -0,0 +1,28 @@ +import tensorflow as tf +import pandas as pd + + +mnist = tf.keras.datasets.mnist + +(x_train, y_train), (x_test, y_test) = mnist.load_data() +x_train, x_test = x_train / 255.0, x_test / 255.0 + +model = tf.keras.Sequential([ + tf.keras.layers.Flatten(input_shape=(28, 28)), + tf.keras.layers.Dense(128, activation='relu'), +]) + +loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) + +model.compile(optimizer='adam', + loss=loss_fn, + metrics=['accuracy']) + +model.fit(x_train, y_train, epochs=10, batch_size=1024) + +my_first_model_path = './model/' +tf.saved_model.save(model, my_first_model_path) + +new_model = tf.saved_model.load(my_first_model_path) + +print(model) \ No newline at end of file diff --git a/utils/oracle_database.py b/utils/oracle_database.py index 0b356e0..c9e7b18 100644 --- a/utils/oracle_database.py +++ b/utils/oracle_database.py @@ -1,4 +1,3 @@ -import cx_Oracle import yaml import os from pathlib import Path @@ -10,7 +9,8 @@ def process_yaml(): with open("../config.yaml") as file: return yaml.safe_load(file) - +# deprecated class due to old cx_Oracle library, new one is oracledb and implemented below. +''' class OracleJSONDatabaseConnection: def __init__(self, data=process_yaml()): # wallet location (default is HOME/wallets/wallet_X) @@ -76,7 +76,7 @@ def get_collection_names(self): returning_object = connection.getSodaDatabase().getCollectionNames(startName=None, limit=0) self.pool.release(connection) return returning_object - +''' @@ -87,13 +87,11 @@ def __init__(self, data=process_yaml()): print('Connection successful.') - def close_pool(self): self.pool.close() print('Connection pool closed.') - def insert(self, collection_name, json_object_to_insert): connection = self.pool.acquire() connection.autocommit = True @@ -110,7 +108,6 @@ def insert(self, collection_name, json_object_to_insert): return 1 - def delete(self, collection_name, on_column, on_value): connection = self.pool.acquire() connection.autocommit = True @@ -121,19 +118,16 @@ def delete(self, collection_name, on_column, on_value): self.pool.release(connection) - def get_connection(self): connection = self.pool.acquire() connection.autocommit = True return connection - def close_connection(self, conn_object): self.pool.release(conn_object) - def get_collection_names(self): connection = self.pool.acquire() connection.autocommit = True @@ -141,6 +135,13 @@ def get_collection_names(self): self.pool.release(connection) return returning_object + def open_collection(self, collection_name): + connection = self.pool.acquire() + returning_object = self.pool.acquire().getSodaDatabase().openCollection(collection_name) + self.pool.release(connection) + return returning_object + + @@ -153,13 +154,11 @@ def __init__(self, data=process_yaml()): print('Connection successful.') - def close_pool(self): self.pool.close() print('Connection pool closed.') - def insert(self, collection_name, json_object_to_insert): connection = self.pool.acquire() connection.autocommit = True @@ -175,8 +174,6 @@ def insert(self, collection_name, json_object_to_insert): self.pool.release(connection) return 1 - - def delete(self, collection_name, on_column, on_value): connection = self.pool.acquire() connection.autocommit = True @@ -187,19 +184,16 @@ def delete(self, collection_name, on_column, on_value): self.pool.release(connection) - def get_connection(self): connection = self.pool.acquire() connection.autocommit = True return connection - def close_connection(self, conn_object): self.pool.release(conn_object) - def get_collection_names(self): connection = self.pool.acquire() connection.autocommit = True @@ -208,9 +202,16 @@ def get_collection_names(self): return returning_object + def open_collection(self, collection_name): + connection = self.pool.acquire() + returning_object = self.pool.acquire().getSodaDatabase().openCollection(collection_name) + self.pool.release(connection) + return returning_object + + def test_class(): - object = OracleJSONDatabaseConnection() + object = OracleJSONDatabaseThickConnection() print(object.pool) object.close_pool()