This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drive_service = google_authenticate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_file(file_id): | |
""" | |
Download file from Google Drive | |
Argument: file_id | |
Returns: downloaded file | |
""" | |
file_id = file_id | |
import io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text_file = read_file('1NrodQrpaw-9xU2lCYo8H8fiW6A1RGdwt') # file id of the picture |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document = text_file.read() | |
print(len(document)) | |
print(document[0:100]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wordcloud = WordCloud().generate(document) | |
plt.imshow(wordcloud, interpolation='bilinear') | |
plt.axis("off") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image_file = read_file("1kHhmo4fj5PqhpH2x_hVY6uUDgf2_G0Tn") | |
# create mask | |
alice_mask = np.array(Image.open(image_file)) | |
# remove stopwords | |
stopwords = set(STOPWORDS) | |
stopwords.add("said") | |
# generate word cloud |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip3 install torch torchvision |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = torch.tensor(([2, 9], [1, 5], [3, 6]), dtype=torch.float) # 3 X 2 tensor | |
y = torch.tensor(([92], [100], [89]), dtype=torch.float) # 3 X 1 tensor | |
xPredicted = torch.tensor(([4, 8]), dtype=torch.float) # 1 X 2 tensor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(X.size()) | |
print(y.size()) |