Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SparseTensor support #67

Open
cavities opened this issue Mar 1, 2022 · 2 comments
Open

SparseTensor support #67

cavities opened this issue Mar 1, 2022 · 2 comments

Comments

@cavities
Copy link

cavities commented Mar 1, 2022

as this python model example: How do i append the SparseTensor?
input as (indices,values,dense_shape)

@galeone
Copy link
Owner

galeone commented Mar 1, 2022

Can you please clarify your question? If you have some code to share it would be better

@cavities
Copy link
Author

cavities commented Mar 2, 2022

my model like:


from tensorflow.keras.layers import Dense, Input
from tensorflow.keras.models import Model
import scipy
import numpy as np

trainX = scipy.sparse.random(1024, 1024)
trainY = np.random.rand(1024, 2)

inputs = Input(shape=(trainX.shape[1],), sparse=True)
outputs = Dense(trainY.shape[1], activation='softmax')(inputs)
model = Model(inputs=inputs, outputs=outputs)
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

steps = 10
for i in range(steps):
  # For simplicity, we directly use trainX and trainY in this example
  # Usually, this is where batches are prepared
    print(model.train_on_batch(trainX, trainY))
tf.saved_model.save(model, "TFKerasModel/abctest")

I load this model use golang
but i don;t know how to put the feature into this model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants