Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,10 +65,15 @@ embedding_dim = 128
|
|
65 |
hidden_dim = 64
|
66 |
num_classes = len(labels)
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
pytorch_model = PyTorchModel(vocab_size, embedding_dim, hidden_dim, num_classes)
|
69 |
|
70 |
-
# Load weights from the
|
71 |
-
for layer_name, weights in zip(['fc1/kernel:0', 'fc1/bias:0', 'fc2/kernel:0', 'fc2/bias:0'],
|
72 |
pytorch_layer_name = layer_name.replace(':0', '')
|
73 |
pytorch_model.state_dict()[pytorch_layer_name].copy_(torch.tensor(weights))
|
74 |
|
|
|
65 |
hidden_dim = 64
|
66 |
num_classes = len(labels)
|
67 |
|
68 |
+
# Load the TensorFlow model
|
69 |
+
model_tf = tflearn.DNN(tflearn.input_data(shape=[None, len(training[0])]))
|
70 |
+
model_tf.load("MentalHealthChatBotmodel.tflearn")
|
71 |
+
|
72 |
+
# Convert the TensorFlow model to a PyTorch model
|
73 |
pytorch_model = PyTorchModel(vocab_size, embedding_dim, hidden_dim, num_classes)
|
74 |
|
75 |
+
# Load weights from the TensorFlow model
|
76 |
+
for layer_name, weights in zip(['fc1/kernel:0', 'fc1/bias:0', 'fc2/kernel:0', 'fc2/bias:0'], model_tf.get_weights()):
|
77 |
pytorch_layer_name = layer_name.replace(':0', '')
|
78 |
pytorch_model.state_dict()[pytorch_layer_name].copy_(torch.tensor(weights))
|
79 |
|