DreamStream-1 commited on
Commit
cd4c7ed
·
verified ·
1 Parent(s): ed12172

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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 tflearn model
71
- for layer_name, weights in zip(['fc1/kernel:0', 'fc1/bias:0', 'fc2/kernel:0', 'fc2/bias:0'], model.get_weights()):
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