तिलक लगवाते समय सिर पर हाथ क्यों रखते हैं ?
jain news jain mantra jain music stavan songs news facts astrology vastu shastra health treatment baby names india tourist place news ayurvedic upchar health disease best places to visit in india and world health blogging hosting domain wishing message blogging blogger tips free adsense friendly template theme for blogger blogspot.com blogger blogspot.com adsense blogging tips in english hindi blogging tips e cards wishing images
MAN LAGO MERO YAAR VIRTI ME ( Lyrics) Jain Diksha Song
MAN LAGO MERO YAAR
VIRTI ME (Lyrics) Jain Diksha Song
Jinke Dil Me Tum Base Ho Jain Gurudev bidai geet Song
Jinke Dil Me Tum Base Ho (Lyrics) Jain Guru bidai Song
Ikshu Ras Ka Kiya Parna (Lyrics) Jain Stavan | Akhatij akshay tritiya
Ikshu Ras Ka Kiya Parna (Lyrics) Jain Stavan | Akhatij akshay tritiya
मुमुक्षु कु. प्रियाबहन बनी महासती श्री प्रणीधि म सा जैन भगवती दीक्षा विधि संपन्न
पेटलावद-दीक्षा विधि सम्पन्न
मुमुक्षु कु. प्रिया बहन बनी महासती श्री प्रणीधि जी म सा
मौनी एकादशी: जैन धर्म का मंगलकारी विशेष पर्व मगसिर सुदी ग्यारस
मौनी एकादशी: जैन धर्म का मंगलकारी विशेष पर्व मगसिर सुदी ग्यारस
25 दिसंबर 2020 शुक्रवार
1 जनवरी से बदल जाएंगे ये 10 नियम, देश के करोड़ों लोगों पर पड़ेगा असर!
1 जनवरी से बदल जाएंगे ये 10 नियम, देश के करोड़ों लोगों पर पड़ेगा असर!
वास्तुशास्त्र के अनुसार क्यों जरूरी है रसोईघर (kitchen)
वास्तुशास्त्र के अनुसार क्यों जरूरी है रसोईघर (kitchen)
विश्व मैत्री उत्सव के रूप में जैन सामयिक फेस्टिवल का विशाल आयोजन
एकता की पटरी पर दौड़ेगी…..सामयिक की गाड़ी…..
बड़ी तपस्या 135 उपवास के तपस्वी का सादगी से हुआ पारणा
धर्मदास गण की अब तक की सबसे बड़ी तपस्या 135 उपवास के तपस्वी का सादगी से हुआ पारणा
HAPPY NEW YEAR 2021 WISHES FOR ALL IN ENGLISH & HINDI
Are you looking for the Happy New Year 2021 Wishes
Happy New Year Wishes 2021, Images, Quotes, GIF, Greetings
Happy New Year 2021 Quotes, Images, Wishes and Greetings
Merry Christmas Animated 3d Gif Images, Wallpapers, Pics
मासखमण शिरोमणि श्री अशोकमुनि जी म.सा.का देवलोक गमन हुआ
युग निर्माता परम् पूजनीय आचार्य प्रवर श्री 1008 *श्री रामलालजी म सा* के शिष्य
घोर तपस्वी शासन दीपक श्री अशोक मुनि जी मा.सा. 9:30 बजे के लगभग हेमगिरि जी मा.सा. से स्वाध्याय सुनते सुनते उनका देवलोक गमन हो गया।।
शासन दीपक घोर तपस्वी राज *श्री अशोक मुनि जी म. सा.* के *दीर्घ तपस्या* के क्रम में "9️⃣8️⃣" वा *मासखमण* की तपस्या पूर्ण की थी
पूज्य महाराज सा आदि ठाणा 4 *मंदसौर (मध्य प्रदेश)* में सुख साता पूर्वक विराज रहे थे।
*98 #मासक्षमण का विश्व कीर्तिमान* धराने वाले जैन जगत की महान विभूति.. बेजोड़ तपस्वी रत्न
आप श्री साधुमार्गी संघ के आचार्य पूज्य श्री रामलाल जी म.सा की आज्ञा मे जिनशासन की अद्भुत प्रभावना कर रहे थे।
पांचवे आरे मे चौथे आरे के समान मासक्षमण के पारणे मासक्षमण (8 - 10 दिन के अंतराल मे) की तपस्या कर रहे थे जिसकी कोई साधारण व्यक्ति कल्पना भी नही कर सकता है।
आप देवलोकगमन से संपूर्ण जैन जगत को अपूरणीय क्षति हुई है।पूरे जैन जगत के लिए बहुत दुःखद समाचार, भगवान महावीर व रामेश शासन का एक कोहिनूर हीरा मोक्ष की यात्रा के लिए ऐसे अचानक जाएगा किसी ने नही सोचा था।
आप शीघ्र अति शीघ्र शाश्वत सुख को प्राप्त करे🙏🏻
गच्छाधीपती पु.आ.दोलत सागर सुरीश्वर जी म.सा. का आगामी चातुर्मास
100 years old..गुरुदेव
जिन शासन के सागर समुदाय के वतॅमान गच्छाधीपती पु.आ.दोलत सागर सुरीश्वर जी म.सा..
पु.सरल स्वभावी आ.नंदीवधॅन सागर सुरीश्वरजी म.सा
तिथोॅधारक पु.आ. हषॅ सागर सुरीश्वर म.सा..
आदी ठाणा 12 का चातृमास मुबई मे...
समस्त लालबाग कालाचोकी जैन संघ मे..
दाँतो के दर्द से छुटकारा कैसे पाए dant dard ka gharelu upay in hindi
dant dard ka gharelu upay in hindi
दाँतो के दर्द से छुटकारा कैसे पाए
रूसी (डैंड्रफ) हटाने के घरेलू उपाय Home remedies to remove dandruff in Hindi
रूसी (डैंड्रफ) हटाने के घरेलू उपाय
Home remedies to remove dandruff in Hindi
जलने और चोट के निशान को हटाने के घरेलू उपाय jale hue ka nishan kaise mitaye
jale hue ka nishan kaise mitaye
जलने और चोट के निशान को हटाने के घरेलू उपाय
chot ke nishan ke liye cream
चेहरे पर बर्फ लगाने से क्या फायदा होता है chehre par barf lagane ke fayde
चेहरे पर बर्फ लगाने से क्या फायदा होता है-
chehre par barf lagane ke fayde
चेहरे पर बर्फ लगाने से चौकाने वाले फायदे
face par ice lagane ke fayde in hindi
अनिद्रा(insomnia) हटाने के कुछ घरेलू उपाय neend aane ke upay in hindi
neend aane ke gharelu nuskhe
अनिद्रा(insomnia) हटाने के कुछ घरेलू उपाय और कारण
neend na aane ka gharelu upay
अनिद्रा(insomnia) हटाने के कुछ घरेलू उपाय क्या है?
चेहरे के दाग धब्बे हटाने के घरेलू उपाय pimple kaise hataye gharelu upay in hindi
pimple hatane ke upay in hindi
दांतों का पीलापन दूर करने के लिए घरेलू उपाय dant ka pilapan kaise dur kare
दांतों का पीलापन दूर करने के लिए घरेलू उपाय
दांत साफ करने के नुस्खे
daant saaf karne ke gharelu nuskhe in hindi
dant ka pilapan kaise dur kare
Dark Circle Treatment at Home in hindi डार्क सर्कल दूर करने का रामबाण उपाय
डार्क सर्कल दूर करने का रामबाण उपाय
Dark Circle Treatment at Home in hindi
Dark Circle Treatment
बाल झड़ने से रोकने के उपाये Baal jhadne ke karan or upay
बाल झड़ने से रोकने के उपाये
Baal jadne ke karan or upay
Baal jadne ke karan or upay
text classification practical part 2
Understanding the Model Architecture
Here is the sequence of layers we defined for our text classification model:
- Word Embedding Layer
- GlobalAveragePooling1D
- Dense
- Dense
We are familiar with what the two dense layers are but what the heck is an embedding layer and what does GlobalAveragePooling1D do?
What is Word Embedding
To understand what a word embedding layer and why it is so important we will compare two very simple sentences. First in human readable form and second in integer encoded form:
Human Readable:
Have a great day
Have a good day
Integer encoded:
[0, 1, 2, 3]
[0, 1, 4, 3]
Mappings: {0: "Have", 1: "a", 2: "great", 3: "day", 4: "good"}
Looking at the sentences above, we as humans know that the two sentences are very similar and pretty well mean the same thing. However when we look at the integer encoded version all we can tell is that the words at index 2 (position 3) are different. We have no idea how different they are.
This is where a word embedding layer comes in. We want a way to determine not only the contents of a sentence but the context of the sentence. A word embedding layer will attempt to determine the meaning of each word in the sentence by mapping each word to a position in vector space. If you don't care about the math or don't understand it think of it as just grouping similar words together.
An example of something we'd hope an embedding layer would do for us:
Maybe "good", "great", "fantastic" and "awesome" are placed close to each other and words like "bad", "horrible", "sucks" are placed close together. We'd also hope that these groupings of words are placed far apart from each other representing that they have very different meanings.
GlobalPooling1D Layer
This layer is nothing special and simply scales down our data's dimension to make it easier computationally for our model in the later layers. Because our word embedding layer maps thousands and thousands of words to a location in vector space they usually do this in a high dimensional vector space. This means when we get our word vectors from the embedding layer they have multiple dimensions and can be scaled down by this layer.
Dense Layers
The last two layers in our network are dense fully connected layers. The output layer is one neuron that uses the sigmoid function to get a value between a 0 and a 1 which will represent the likelihood of the review being positive or negative. The layer before that contains 16 neurons with a relu activation function designed to find patterns between different words present in the review
Validation Data
For this specific model we will introduce a new idea of validation data. In the last tutorial when we trained the models accuracy after each epoch on the current training data, data the model had seen before. This can be problematic as it is highly possible the a model can simply memorize input data and its related output and the accuracy will affect how the model is modified as it trains. So to avoid this issue we will sperate our training data into two sections, training and validation. The model will use the validation data to check accuracy after learning from the training data. This will hopefully result in us avoiding a false confidence for our model.
We can split our training data into validation data like so:
x_val = train_data[:10000]
x_train = train_data[10000:]
y_val = train_labels[:10000]
y_train = train_labels[10000:]
Training the Model
We will train the model using the code below:
fitModel = model.fit(x_train, y_train, epochs=40, batch_size=512, validation_data=(x_val, y_val), verbose=1)
Testing the Model
To have a look at the results of our accuracy we can do the following:
results = model.evaluate(test_data, test_labels)
print(results)
Saving the Model
Up until this point we have simply been retraining our models every time that we wanted to use them. This is fine for now on our small models that take only a few seconds to train but for larger models this is not realistic. Luckily for us keras provides a very easy way to save our models:
model.save("model.h5") # name it whatever you want but end with .h5
Loading the Model
Now that we have saved a trained model we never need to retrain it! We can simply load a saved model in by using the following. Simply ensure that the .h5 file is in the same directory as your python script.
model = keras.models.load_model("model.h5")
Making Predictions
Now it is time to used our saved model to make predictions. Now this is a little bit harder than it looks because we need to consider the following:
– our model accepts integer encoded data
– our model needs reviews that are of length 250 words
This means we can’t just pass any string of text into our model. It will need to be reshaped and reformed to meet the criteria above.
Transforming our Data
The data I’ll use for this tutorial will be simple raw text data of a movie review of one of my favorite movies, the lion king. I’m storing this data in a text file called “test.txt” that you can download here.
To start we will need to integer encode the data. We will do this using the following function:
def review_encode(s):
encoded = [1]
for word in s:
if word.lower() in word_index:
encoded.append(word_index[word.lower()])
else:
encoded.append(2)
return encoded
Next we will open our text file, read in each of the reviews (in this case just one) and use the model to predict whether it is positive or negative.
with open("test.txt", encoding="utf-8") as f:
for line in f.readlines():
nline = line.replace(",", "").replace(".", "").replace("(", "").replace(")", "").replace(":", "").replace("\"","").strip().split(" ")
encode = review_encode(nline)
encode = keras.preprocessing.sequence.pad_sequences([encode], value=word_index["<PAD>"], padding="post", maxlen=250) # make the data 250 words long
predict = model.predict(encode)
print(line)
print(encode)
print(predict[0])
practical coding loading the fashion mnist datasets neural network
Installing Tensorflow 2.0
Before we can start loading in the data that we will feed our neural network we must install tensorflow 2.0. If you are on windows it is as easy as typing the following (this is the cpu version):
pip install -q tensorflow==2.0.0-alpha0
If you are having any troubles try following the instructions on the tensorflow website.
Installing MatPlotLib
The last thing to install is MatPlotLib. If you are unfamiliar with matplotlib it is a python module that allows us to visualize and graph data. Install it with the pip command below:
pip install matplotlib
The Importance of Data
Data is by far the most important part of any neural network. Choosing the right data and transforming it into a form that the neural network can use and understand is vital and will affect the networks performance. This is because the data we pass the network is what it will use to modify its weights and biases!
Keras Datasets
In these first few tutorials we will simply use some built in keras datasets which will make loading data fairly easy. The dataset we will use to start is the Fashion MNIST datset. This dataset contains 60000 images of different clothing/apparel items. The goal of our network will be to look at these images and classify them appropriately To load our first dataset in we will do the following:
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
data = keras.datasets.fashion_mnist
Now we will split our data into training and testing data. It is important that we do this so we can test the accuracy of the model on data it has not seen before.
(train_images, train_labels), (test_images, test_labels) = data.load_data()
Finally we will define a list of the class names and pre-process images. We do this by dividing each image by 255. Since each image is greyscale we are simply scaling the pixel values down to make computations easier for our model.
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
train_images = train_images/255.0
test_images = test_images/255.0
Full Code
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
data = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = data.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
train_images = train_images/255.0
test_images = test_images/255.0
Creating the Model
Now time to create our first neural network model! We will do this by using the Sequential object from keras. A Sequential model simply defines a sequence of layers starting with the input layer and ending with the output layer. Our model will have 3 layers, and input layer of 784 neurons (representing all of the 28x28 pixels in a picture) a hidden layer of an arbitrary 128 neurons and an output layer of 10 neurons representing the probability of the picture being each of the 10 classes.
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28,28)),
keras.layers.Dense(128, activation="relu"),
keras.layers.Dense(10, activation="softmax")
])
Training the Model
Now that we have defined the model it is time to compile and train it. Compiling the model is just picking the optimizer, loss function and metrics to keep track of. Training is the process of passing our data to the model.
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.fit(train_images, train_labels, epochs=5)
Testing the Model
Now that the model has been trained it is time to test it for accuracy. We will do this using the following line of code:
test_loss, test_acc = model.evaluate(test_images, test_labels)
print('\nTest accuracy:', test_acc)
In the next tutorial we will use our trained model to make predictions on specific images
Using the Model
Now that we have trained the model it is time to actually use it! We will pick a few images from our testing data, show them on the screen and then use the model to predict what they are.
To make predictions we use our model name and .predict() passing it a list of data to predict. It is important that we understand it is used to make MULTIPLE predictions and that whatever data it is expecting mus be inside of a list. Since it is making multiple predictions it will also return to use a list of predicted values.
predictions = model.predict(test_images)
Now we will display the first 5 images and their predictions using matplotlib.
plt.figure(figsize=(5,5))
for i in range(5):
plt.grid(False)
plt.imshow(test_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[test_labels[i]])
plt.title(class_names[np.argmax(predictions[i])])
plt.show()
Now that we have trained the model it is time to actually use it! We will pick a few images from our testing data, show them on the screen and then use the model to predict what they are.
To make predictions we use our model name and .predict() passing it a list of data to predict. It is important that we understand it is used to make MULTIPLE predictions and that whatever data it is expecting mus be inside of a list. Since it is making multiple predictions it will also return to use a list of predicted values.
predictions = model.predict(test_images)
Now we will display the first 5 images and their predictions using matplotlib.
plt.figure(figsize=(5,5))
for i in range(5):
plt.grid(False)
plt.imshow(test_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[test_labels[i]])
plt.title(class_names[np.argmax(predictions[i])])
plt.show()
Featured Post
Happy Diwali 2025: Best 100 Diwali Wishes, Quotes, Messages, WhatsApp Status, Imagesdiwali 2025 diwali date
Happy Diwali 2025: Best 100 Diwali Wishes, Quotes, Messages, WhatsApp Status, Images
advertisement
Advertisement
-
जैन दीक्षा / दिक्षार्थी / संयम पर शायरी Shayri For Jain Diksha / Diksharthi / Sanyam in Hindi
-
Siddhagiri Na Shikharo Bole Lyrics Jain Stavan
-
जैन तपस्या जैन तप पर शायरी Shayri for Jain Tapasya Jain Tap
