Categories
Mastering Development

How to build federated_averaging_process from custom federated dataset that loads from CSV file

My problem is a continue to this question How to create federated dataset from a CSV file? i manage to load a federated dataset from a given csv file and load both the train and the test data. My question now is how to reproduce a working example to build an iterative process that performs […]

Categories
Mastering Development

How to upload my training data into google for Tensorflow cloud training

I want to train my keras model in gcp. My code: this is how I load the dataset dataset = pandas.read_csv(‘USDJPY.fx5.csv’, usecols=[2, 3, 4, 5], engine=’python’) this is how i trigger cloud training job_labels = {"job": "forex-usdjpy", "team": "xxx", "user": "xxx"} tfc.run(requirements_txt="./requirements.txt", job_labels=job_labels, stream_logs=True ) Right before my model, which shouldn’t make much of a […]

Categories
Mastering Development

Boolean Labels Training with Keras causes the error “Please provide data which shares the same first dimension”

So, here is what I am trying to do. My model has to receive a number of training samples, each a conjunction of Boolean literals (i.e. a vector of 0 or 1s) assigned with a truth value. Learning from the samples, it must be able to receive some test vector and determine its truth value. […]

Categories
Mastering Development

Incremental learning in keras

I am looking for a keras equivalent of scikit-learn’s partial_fit : https://scikit-learn.org/0.15/modules/scaling_strategies.html#incremental-learning for incremental/online learning. I finally found the train_on_batch method but I can’t find an example that shows how to properly implement it in a for loop for a dataset that looks like this : x = np.array([[0.5, 0.7, 0.8]]) # input data y […]

Categories
Mastering Development

ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32 – LSTM Implementation( tensorflow 2.0.0)

I am trying to test different types of implementations of LSTM and facing this error in the code while predicting. Tensorflow version – ‘2.0.0’ I am not removing this question as I still need to know what went wrong. Do i always need to worry about having float32 as the datatypes while feeding the models? […]

Categories
Linux Mastering Development

ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis 1 of input shape

My code : `import numpy from keras.models import Sequential from keras.layers import Dense,Dropout,Flatten,BatchNormalization,Activation from keras.layers.convolutional import Conv2D,MaxPooling2D from keras.constraints import max_norm from keras.utils import np_utils from keras.datasets import cifar10 #set random seed for the purpose of reproductivty seed = 21 #loading in the data (x_train,y_train),(x_test,y_test) = cifar10.load_data() #normalize the inputs from 0-255 to between 0 […]

Categories
Mastering Development

Numpy Array Index Error: IndexError: boolean index did not match indexed array along dimension 0; dimension is 16

the following code throws an error: Traceback (most recent call last): File “training.py”, line 19, in <module> preds = model.predict(x_test, test_df) File “D:\brand\models\lstm_detection_model\lstm_brand_detection.py”, line 46, in predict output = [‘ ‘.join(np.array(token_df[i])[np.array(ind[i])]) for i in range(len(ind))] File “D:\brand\models\lstm_detection_model\lstm_brand_detection.py”, line 46, in <listcomp> output = [‘ ‘.join(np.array(token_df[i])[np.array(ind[i])]) for i in range(len(ind))] IndexError: boolean index did not match […]

Categories
Artificial Intelligence (AI) Mastering Development

How to implement a LSTM (classification) with multiple labels per input?

I would like to develop a LSTM because I have a variable input matrix. I am zero padding to a specific length of 800. However, I am not sure of how to classify a certain situation when each input matrix has multiple labels inside. {0,1,2} Data shape (250,800,4) x_train(150,800,4) y_train(150,800,1) x_test(100,800,4) y_test(100,800,1) How to proceed […]

Categories
Artificial Intelligence (AI) Mastering Development

How can I implement a 1D CNN in front of my LSTM network

At the moment I reshape my X_train like this: X_train = input.reshape(1,1,12) model = Sequential() model.add(LSTM(100,input_shape=(1, 12))) model.add(Dense(100, activation=’relu’)) model.add(Dropout(0.5)) model.add(Dense(9, activation=’sigmoid’)) But now I am thinking of implementing a 1D CNN in front of this LSTM layer. Does anybody know how this should be done?

Categories
Mastering Development

Triplet Loss with “static” anchor: model with shared layers gives different embeddings of the same image in the batch

I’m playing with the concept of Triplet Loss in Keras 2.3.1 and Tensorflow 2.1.0. I’m trying to implement a loss function where the anchor image is the same for all the triplets. The idea is to train the model to recognize hand-drawn images of the anchor through triplet loss. Code is inspired by: https://github.com/AdrianUng/keras-triplet-loss-mnist/blob/master/Triplet_loss_KERAS_semi_hard_from_TF.ipynb def […]