Nothing Special   »   [go: up one dir, main page]

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

Bump tf version #281

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Bump tf version #281

wants to merge 32 commits into from

Conversation

mohazahran
Copy link
Collaborator
@mohazahran mohazahran commented Sep 20, 2024

Migrating ml4ir to tf 2.16.1 and jvm to 1.0.0-rc1

@@ -1,2 +1,2 @@
FROM cimg/openjdk:11.0
COPY --from=cimg/python:3.9.7 / /
COPY --from=cimg/python:3.11 / /
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran would be good to add context for why you upgraded to python311

@@ -217,7 +217,13 @@
<dependencies>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<artifactId>tensorflow-core-api</artifactId>
<version>1.0.0-rc.1</version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran did you check if we could upgrade to 1.0.0 without upgrading on the python side? Also "rc" is usually a beta release I believe.

Comment on lines +32 to +54
println("\nsavedModelBundle:\n")
savedModelBundle.graph().operations().asScala.foreach(op => println(op.name()))

//val metaGraphDef = MetaGraphDef.parseFrom(savedModelBundle.metaGraphDef())
//val signatureMap = metaGraphDef.getSignatureDefMap
//val signatureKey = "serving_tfrecord"
//val signatureDef = signatureMap.get(signatureKey)

//val inputInfo = signatureDef.getInputsMap.asScala
//val outputInfo = signatureDef.getOutputsMap.asScala



private val session = savedModelBundle.session()

// Initialize variables if an init op exists
try {
session.runner().addTarget("init_op").run() // Replace "init_op" with actual name
} catch {
case e: Exception => println("No init_op found or initialization failed.")
}

// Run the initialization operation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran Do you want to clean this up or let it be for context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to leave it so that we can track debugging attempts. I will add comments.

Comment on lines +254 to +266
# np.set_printoptions(formatter={'all':lambda x: str(x.decode('utf-8')) if isinstance(x, bytes) else str(x)},
# linewidth=sys.maxsize,
# threshold=sys.maxsize, # write the full vector in the csv not a truncated version
# legacy="1.13") # enables 1.13 legacy printing mode


# np.set_printoptions(formatter={
# 'all': lambda x: str(x.decode('utf-8', errors='ignore')) if isinstance(x, bytes) else str(x)
# }, linewidth=sys.maxsize, threshold=sys.maxsize, legacy="1.13")

# for col in predictions_df.columns:
# if isinstance(predictions_df[col].values[0], bytes):
# predictions_df[col] = predictions_df[col].str.decode('utf8')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran Can you remove unused code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it commented as it seems it really affect the java integration test. I will add comments to reflect that.

Copy link
Collaborator
@lastmansleeping lastmansleeping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran I have closed the work, but I'd request these 2 changes

  • split it into two PRs against a dev_tf branch - one for python (merge it) and one for jvm (leave it as is)
  • add in-line comments (either on this PR or the split up ones) explaining your changes/findings to add context for future

@@ -76,8 +76,8 @@ def test_csv_and_tfrecord(self):
)

# Check if the loss and accuracy on the test set is the same
assert np.isclose(csv_loss, 0.56748, rtol=0.01)
assert np.isclose(csv_mrr, 0.70396, rtol=0.01)
assert np.isclose(csv_loss, 0.31154385209083557, rtol=0.01)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran do you know why these might have changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect these changes specially with this type of migration due to changes to how models gets trained under the hood. As long as numbers seems sane, loss if decreasing I believe it should be fine.

Comment on lines +73 to +77
# default_model = kmodels.load_model(
# os.path.join(self.output_dir, "final", "default"), compile=False
# )
# assert ServingSignatureKey.DEFAULT in default_model.signatures
# default_signature = default_model.signatures[ServingSignatureKey.DEFAULT]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran cleanup unused code

Comment on lines +517 to +544
# def get_default_tensor(self, feature_info, sequence_size):
# """
# Get the default tensor for a given feature configuration
# Parameters
# ----------
# feature_info: dict
# Feature configuration information for the feature as specified in the feature_config
# sequence_size: int, optional
# Number of elements in the sequence of a SequenceExample
# Returns
# -------
# tf.Tensor
# Tensor object that can be used as a default tensor if the expected feature
# is missing from the TFRecord
# """
# if feature_info.get("tfrecord_type", SequenceExampleTypeKey.CONTEXT) == SequenceExampleTypeKey.CONTEXT:
# return tf.constant(
# value=self.feature_config.get_default_value(feature_info), dtype=feature_info["dtype"],
# )
# else:
# return tf.fill(
# value=tf.constant(
# value=self.feature_config.get_default_value(feature_info),
# dtype=feature_info["dtype"],
# ),
# dims=[sequence_size],
# )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohazahran delete

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

Successfully merging this pull request may close these issues.

2 participants